String* str; //string variable
System::IO::StreamReader* reads = new System::IO::StreamReader(S"hello.txt");
//new instance of StreamReader
str = reads->ReadToEnd(); //read the whole file using the ReadToEnd() method
reads->Close();
christ this sort of code is kinda scaring me into not learning VC++mutant said:Are trying to do this using Managed Extensions? If yes then you can use the System::IO::StreamReader to read in the file and then assign it to a variable:
Code:String* str; //string variable System::IO::StreamReader* reads = new System::IO::StreamReader(S"hello.txt"); //new instance of StreamReader str = reads->ReadToEnd(); //read the whole file using the ReadToEnd() method reads->Close();