default directory when reading TXT files...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all!

I've created an ASP.NET project using Visual Studio 2003 and C#. The project is quite basic in that it simply needs to read in the contents of a text file (.txt).

I have the StreamReader in place, but my problem arises when trying to local the file. I added my text file to my project in VS. I thought just putting the filename would locate the file thinking the default directory is the project directory: StreamReader("myFile.txt").

However, the program does not find the file. Instead, when I display the 'Path.GetFullPath(".")' I get: "C:\WINNT\system32".

I need the file to be read on my development machine (which is "localhost") and without program changes or hard-coding directory information, I also need it to read the file on my server when I copy the project out to the web.

Any suggestions would be greatly appreciated. I'm confident this issue is simple, but not from where I sit right now.

Thank you!

Mark
 
¤ Hello all!
¤
¤ I've created an ASP.NET project using Visual Studio 2003 and C#. The project is quite basic in that it simply needs to read in the contents of a text file (.txt).
¤
¤ I have the StreamReader in place, but my problem arises when trying to local the file. I added my text file to my project in VS. I thought just putting the filename would locate the file thinking the default directory is the project directory: StreamReader("myFile.txt").
¤
¤ However, the program does not find the file. Instead, when I display the 'Path.GetFullPath(".")' I get: "C:\WINNT\system32".
¤
¤ I need the file to be read on my development machine (which is "localhost") and without program changes or hard-coding directory information, I also need it to read the file on my server when I copy the project out to the web.
¤
¤ Any suggestions would be greatly appreciated. I'm confident this issue is simple, but not from where I sit right now.
¤

Try Request.PhysicalApplicationPath.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top