Wer*_*ver 2 c# streamreader windows-ce .net-2.0 textreader
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());
}
}
}
Run Code Online (Sandbox Code Playgroud)
这在我创建Windows应用程序时非常有效.
当我在设备应用程序中使用相同的代码时 - Windows CE我收到错误:

使用:.Net 2.0,visual Studio 2005
您的设备没有c驱动器.更换
string fileLoc = @"c:\wms.txt";
Run Code Online (Sandbox Code Playgroud)
同
string fileLoc = @"wms.txt";
Run Code Online (Sandbox Code Playgroud)
似乎根文件夹会自动添加到您的路径中 \