如何阅读* .file
我在阅读20110531.file时遇到问题,
1)首先我创建一个文本文件20110531.txt。
2)我正在将其压缩为名为20110531.zip的zip格式。
3)现在,当我解压缩文件时,它没有创建一个名为20110531.txt的文本文件,否则它创建的文件没有格式,称为20110531而不是txt格式。
4)当我尝试使用记事本打开文件时它很好,但我的代码只读取文本文件。
5)我用来读取文本文件的代码
我的代码是
private void button1_Click(object sender, EventArgs e) { string Path1 = (string)(Application.StartupPath + "\\TEMP\\futures" + "\\" + name_futures); StreamReader reader1 = File.OpenText(Path1); string str = reader1.ReadToEnd(); reader1.Close(); reader1.Dispose(); }
5)我的代码只读取文本文件任何人都可以请我说我应该在我的代码中更改为20110531
提前致谢
如果你能给我们一些代码,我们可以更具体..
这个问题的教程:
http://www.csharp-examples.net/filestream-open-file/
http://www.csharp-examples.net/filestream-read-file/
http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx
http://msdn.microsoft.com/en-us/library/system.io.streamreader%28v=vs.71%29.aspx
希望它会帮助你..
我会打电话
string str = System.IO.File.ReadAllText(path1);
阅读所有文字。 请参阅此MSDN参考文章 。