开发者

how to read a *.file [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I am having a problem in reading 20110531.file ,

1) First I am creating a text file 20110531.txt.

2) I am compressing it into a zip format called 20110531.zip .

3) Now when i unzip the file its not creating a text file called 20110531.txt else its creating a file without format called 20110531 not a txt format .

4) When i am trying the file to open with notepad its fine , but my code reads only text file .

5)the cod开发者_JAVA技巧e i use to read text file

My code is

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)my code reads only text file can anyone please say me what i should change in my code to read 20110531

Thanks in Advance


IF you can give us some code, we can be more specific..

tutorials for this question:

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

hope it will help you..


I would call

string str = System.IO.File.ReadAllText(path1);

to read all text. See this MSDN reference article.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜