they
January 14th, 2005, 10:46 PM
Hi,
I'm currently building my first managed c++ application using visual c++ 2003 .net, and I am having a problem reading strings from a text file. Here is an example of the contents of the file:
path_to_resource_file c:/app/files/res.txt
path_to_desc_file c:/app/files/desc.txt
My current code is as follows:
FileStream* pr = new FileStream(mPath, FileMode::Open);
BinaryReader * rp = new BinaryReader(pr);
String* fileDescription = rp->ReadString();
String* amp = rp->ReadString();
this->ampDataBox->Text = amp;
rp->Close();
This unfortunately throws the complete file into the text box of the application.
What I want to be able to do is read the first string (path_to_resource_file) into fileDescription and then read the second string (c:/app/files/res.txt) into amp.
using standard c++ this was easy:
ifstream readFile(mPath, ios::in | ios::binary);
string fileDescription = " ";
string amp = " ";
readFile >> fileDescription >> amp;
In the above example fileDescription now equals "path_to_resource_file " and amp equals "c:/app/files/res.txt"
How can I read the strings as above in managed c++?
I'm currently building my first managed c++ application using visual c++ 2003 .net, and I am having a problem reading strings from a text file. Here is an example of the contents of the file:
path_to_resource_file c:/app/files/res.txt
path_to_desc_file c:/app/files/desc.txt
My current code is as follows:
FileStream* pr = new FileStream(mPath, FileMode::Open);
BinaryReader * rp = new BinaryReader(pr);
String* fileDescription = rp->ReadString();
String* amp = rp->ReadString();
this->ampDataBox->Text = amp;
rp->Close();
This unfortunately throws the complete file into the text box of the application.
What I want to be able to do is read the first string (path_to_resource_file) into fileDescription and then read the second string (c:/app/files/res.txt) into amp.
using standard c++ this was easy:
ifstream readFile(mPath, ios::in | ios::binary);
string fileDescription = " ";
string amp = " ";
readFile >> fileDescription >> amp;
In the above example fileDescription now equals "path_to_resource_file " and amp equals "c:/app/files/res.txt"
How can I read the strings as above in managed c++?