basic file I/O issue



I have a text file that is just a list of integers separated by a
space. In C++ I could do something like:

ifstream fin("filename.txt");

int x, y, z;
fin >> x >> y >> z;

to read the integers in.

How do I do that in C# with .NET IO?

Do I have to just read it all in as a giant string and then parse the
string?

.



Relevant Pages

  • Re: unique numbers using srand( ) and rand( ) functions in C++[ caution long post]
    ... /*for declaring objects of the ofstream and ifstream classes for a data ... int main ... /*consume # character betwwen numbers of each record in data file or the ... return SUCCESS; ...
    (alt.comp.lang.learn.c-cpp)
  • Re: std::ifstream
    ... "David Wilkinson" wrote: ... If I pass to my ifstream object a constant filePath ... int linesCount; ...
    (microsoft.public.vc.language)
  • Slow ifstream close when accessing network files
    ... The code in question opens an ifstream, calls seekgwith a non zero value, ... unsigned int threadHandle = 0; ... ifstream *ifs; ... void TestFileAccess2{ ...
    (microsoft.public.vc.stl)
  • Re: std::ifstream
    ... If I pass to my ifstream object a constant filePath it works, but it doesn't as soon as I pass it a variable. ... int linesCount; ... You have to use c_strmember to get const char* from a string; ...
    (microsoft.public.vc.language)
  • Re: Read from txt file
    ... When you read an int using>>, it will stop reading when it reaches the ... ifstream input; ... while (input>> num) ...
    (comp.lang.cpp)