Link to home
Start Free TrialLog in
Avatar of mike_pro
mike_pro

asked on

Reading a file in c# using VS2005

Im currently reading a file off of my desktop and processing the contents. I want to attach this file to the project so that wherever this program is used it will still work.
I tried, project -> add component which adds the text file. However when using Streamreader etc what is the address that you put in? I tried just the name of the file e.g.

StreamReader t = new StreamReader("textfile.txt");

but this didn't work.

Cheers guys.
ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You have to put in the absolute path.

So if your going to use a file from your desktop then you'll go to

C:\Documents and Settings\USER\Desktop\file.txt

Hope this helps
Avatar of mike_pro
mike_pro

ASKER

Awesome, thanks for the help!
> Awesome, thanks for the help!
you're welcome. Long time ago it took me ages to find out why things weren't copied... Glad to be of help ;-)