문제

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

도움이 되었습니까?

해결책

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 \

다른 팁

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";
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top