返回首页

如何保存在文本文件中的数据,以及如何从文本文件中提取数据,使用C#点净?

回答

评论会员:CPallini 时间:2012/02/06
有周围很多教程。见,例如]
评论会员:。arunrv 时间:2012/02/06
U可以使用名称空间使用System.IO
然后使用此代码

//This code is used to write data into .txt file...



FileStream fs = new FileStream("E:\\a.txt", FileMode.Create, FileAccess.Write);

StreamWriter write = new StreamWriter(fs);

string a_variable = "more advanced services to mobile or nomadic computing devices";

write.Write(a_variable);

write.Close();

fs.Close();

 



//This code is used to read data from.txt file...



FileStream fs1 = new FileStream("E:\\a.txt", FileMode.Open);

StreamReader read = new StreamReader(fs1);

string b = read.ReadToEnd();

Console.WriteLine(b);

read.Close();

fs1.Close();
评论会员:lukeer 时间:2012/02/06
我{A1}]类开始进入你的程序保存的数据

,或取决于你有什么样的数据在您的应用程序,{A2}

先打为您确切的标题加C#是一个页面,告诉你如何做到这一点。BobJanova
评论会员:游客 时间:2012/02/06
从文件读***************{BR}写入文件codeprelang="cs"spanclass="code-keyword"try/span{ spanclass="code-comment"///spanspanclass="code-comment"PassthefilepathandfilenametotheStreamWriterConstructor/spanStreamWritersw=spanclass="code-keyword"new/spanStreamWriter(spanclass="code-string""/spanspanclass="code-string"C:\\Test.txt"/span); spanclass="code-comment"///spanspanclass="code-comment"Writealineoftext/spansw.WriteLine(spanclass="code-string""/spanspanclass="code-string"HelloWorld!!"/span); spanclass="code-comment"///spanspanclass="code-comment"Writeasecondlineoftext/spansw.WriteLine(spanclass="code-string""/spanspanclass="code-string"FromtheStreamWriterclass"/span); spanclass="code-comment"///spanspanclass="code-comment"Closethefile/spansw.Close();}spanclass="code-keyword"catch/span(Exceptione){Console.WriteLine(spanclass="code-string""/spanspanclass="code-string"Exception:"/span+e.Message);}spanclass="code-keyword"finally/span{Console.WriteLine(spanclass="code-string""/spanspanclass="code-string"Executingfinallyblock."/span);}/pre/code的
md_refay
评论会员:游客 时间:2012/02/06
是的,我们可以使用像其他许多技术的AjaxPHP的JavaScript的Java的jQuery的jQuery的AJAX和PHP是一个很好的组合参阅本{A3的}]