Question

private void button1_Click(object sender, EventArgs e)
    {
        string fileLoc = @"c:\wms.txt";

        if (File.Exists(fileLoc))
        {
            using (TextReader tr = new StreamReader(fileLoc))
            {
                MessageBox.Show(tr.ReadLine());
            }
        }
    }

This works perfectly in when I create a Windows Application.

When I use the same code in a Device application - Windows CE i get error:

enter image description here

Using: .Net 2.0 , visual Studio 2005

Was it helpful?

Solution

Your device does not have a c drive. Replace

string fileLoc = @"c:\wms.txt";

with

string fileLoc = @"wms.txt";

It seems that the root folder is automatically added to your path with a \

OTHER TIPS

Windows CE does not have a concept of drive letters. Your path there should simply be @"\wms.txt".

try

string fileLoc = @"c:\wms.txt";

or

string fileLoc = "c:\\wms.txt";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top