Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The following code works on winXP, Win7 64bit, but not on win7 32bit. I get an error saying can't find file 'C:\Users\John\Documents\notes.txt'.

using (StreamReader sr = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\notes.txt"))
Posted

Try printing the value of Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\notes.txt") as a string, to see why it is different.
 
Share this answer
 
Try this instead:

string pfile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "notes.txt");

using (StreamReader sr = new StreamReader(pfile);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900