Search code examples
c#.netcompact-framework

Compact Framework: A problem with reading a file


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 ?


Solution

  • 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...