1

I have added a text file to my project with intend of using it to contain strings taken from the form on the local page - I mean, you input the string into textfield, hit the button and the string is written with TextWriter into entries.txt just the way I always did it in C#. The problem is that when I give "entries.txt" as an argument it doesn't save the data to entries.txt in the same folder where *.aspx file in question is (that is, project's folder) but, for some weird reason, creates a new txt file in C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE. So I guess I need to give a full path to the file. I can't just give the path to the project on my HDD because I need to open it on different computers so I tried @"localhost:2439/WebSite1/entries.txt" based on the address of the *.aspx file, but it doesn't work. What path should I give for file that is in the same folder as the file with code?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
user530809
  • 59
  • 1
  • 2
  • 5

1 Answers1

0

Check out Server.MapPath(), which will map a website path to the local, physical path.

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466