I have a file stored in the same dir as my application. I try to load that file but I get an error (not found)
StreamReader str = new StreamReader("list.txt");
so, what path to the file I must declare to read it ?
I have a file stored in the same dir as my application. I try to load that file but I get an error (not found)
StreamReader str = new StreamReader("list.txt");
so, what path to the file I must declare to read it ?
Windows CE doesn't have the concept of "current directory". The OS tries to open \list.txt when passing "list.txt". You always have to specify the full path to the file.
In full framework I use:
string dir = Path.GetDirectory(Assembly.GetExecutingAssembly().Location);
string filename = Path.Combine(dir, "list.txt");
StreamReader str = new StreamReader(filename);
I don't know if in compact-framework this works, I cannot try now, sorry...
For the Compact Framework you can get the executing assembly location by using the code base path as follows:
string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
string filename = Path.Combine(dir, "list.txt");
StreamReader str = new StreamReader(filename);