How can I read something from a text.log file
-
HI How can I work with text files in C# .net? For example I want to open a text file, read portion from the file and then display that portion on the pop-up message.
that should not take much code first use a System.IO.FileSteam(fileName, FileMode, FileAccess, FileShare) then pass this stream into a System.IO.StreamReader then use streamReader.ReadLine() to return each line as a String, or there are other options in the stream reader to read from certain offsets, and certain lengths, then whatever data you capture this way can be passed to the MessageBox.Show(message, boxTitle, Buttons, Icon)
-
HI How can I work with text files in C# .net? For example I want to open a text file, read portion from the file and then display that portion on the pop-up message.
System.File.ReadAllLines("c:\text.log"); will give you a string array, ReadAllText will give a single string.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
System.File.ReadAllLines("c:\text.log"); will give you a string array, ReadAllText will give a single string.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
That will teach me to read documentationin advance, not just when I'm stuck. How many times in my code do I open a file, called ReadToEnd, or iterate through the file populating my array manually...:doh: Cheers (again!) Christian for that one.