如何在.net framework 3.5中使用readlines方法 [英] How to use readlines method in .net framework 3.5

查看:91
本文介绍了如何在.net framework 3.5中使用readlines方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,我在.net framework 3.5中的File.ReadLines中出错。



我无法使用File.readAlllines给出这个错误来自File.WriteAlllines方法



请建议





  string  Activestorelist =  @  C:\Activestores_default.txt; 
var file1 = File.ReadLines(Activestorelist);
var file2 = File.ReadAllLines(savePath);
var onlyInFileA = file1.Except(file2);
File.WriteAllLines(savePath,onlyInFileA);

解决方案
在良好醇 3.5只能使用读取,或的ReadLine WriteLine



 使用 System.IO; 

...

StreamReader file = new StreamReader( @ C:\ Activestores_default.txt);


string 行;

while ((line = file.ReadLine())!= null
{
// 您的代码在这里......
}





您还需要使用System.IO库中的StreamReader。











来源

http://msdn.microsoft.com/en-us/library/aa287535(v=vs.71) .aspx [ ^ ]


I have the following code where I am having error in File.ReadLines in .net framework 3.5.

I am not able to use File.readAlllines as after giving this the error comes in File.WriteAlllines method

Please suggest


string Activestorelist = @"C:\Activestores_default.txt";
var file1 = File.ReadLines(Activestorelist);
var file2 = File.ReadAllLines(savePath);
var onlyInFileA = file1.Except(file2);
File.WriteAllLines(savePath, onlyInFileA);

解决方案

In good ol' 3.5 you can only use Read, ReadLine or WriteLine

using System.IO;

...

StreamReader file = new StreamReader(@"C:\Activestores_default.txt");


string line;

while((line = file.ReadLine()) != null)
{
   // your code here...
}



You also need to use StreamReader from System.IO library.





Source
http://msdn.microsoft.com/en-us/library/aa287535(v=vs.71).aspx[^]


这篇关于如何在.net framework 3.5中使用readlines方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆