سؤال

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