C# 如何在windows mobile上逐行运行文本文件?

C# 如何在windows mobile上逐行运行文本文件?,c#,windows-mobile,C#,Windows Mobile,在PC上的WinForm中,我经常这样运行: FileStream FS = null; StreamWriter SW = null; FS = new FileStream(@"\Items.txt", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); SW = new StreamWriter(FS, Encoding.Default); while (SW.Peek() != -1) { TEMP = (SW.

在PC上的WinForm中,我经常这样运行:

FileStream FS = null;
StreamWriter SW = null;
FS = new FileStream(@"\Items.txt", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
SW = new StreamWriter(FS, Encoding.Default);
while (SW.Peek() != -1)
{
   TEMP = (SW.ReadLine());
}
但是,当我在Windows mobile上尝试此操作时,我发现错误:

Error   1   'System.IO.StreamWriter' does not contain a definition for 'Peek' and no extension method 'Peek' accepting a first argument of type 'System.IO.StreamWriter' could be found (are you missing a using directive or an assembly reference?)
Error   2   'System.IO.StreamWriter' does not contain a definition for 'ReadLine' and no extension method 'ReadLine' accepting a first argument of type 'System.IO.StreamWriter' could be found (are you missing a using directive or an assembly reference?)
怎么做


谢谢如果你想读东西,用读卡器而不是写卡器如果你想读东西,用读卡器而不是写卡器你是说这样的吗

using (var reader = File.OpenText("\\items.txt"))
{
    while(reader.Peek() > 0)
    {
        var line = reader.ReadLine();
        // do something with the line here
    }
}

我看不出你的代码在桌面上是如何工作的,因为ReadLine和Peek都不存在于桌面上。

你的意思是这样的

using (var reader = File.OpenText("\\items.txt"))
{
    while(reader.Peek() > 0)
    {
        var line = reader.ReadLine();
        // do something with the line here
    }
}

即使在桌面上,我也看不出您的代码是如何工作的,因为ReadLine和Peek都不存在于桌面上。

试试这个,读取字符串中的所有数据。然后使用\n拆分字符串,然后读取字符串数组中的每个值。

尝试此操作,读取字符串中的所有数据。然后使用\n拆分字符串,然后读取字符串数组中的每个值。

如前所述,您使用的是a而不是a


如前所述,您使用的是a而不是a


@黄金不知道文件的格式,我真的不能help@Gold如果不知道文件的格式,我真的帮不上忙。这就是我想到它的原因。这是一个移动设备,这就是我想到它的原因。