I'm trying to open and read a file line by line and save each line to the array.
//this part is just openfiledialog and get the filename
OpenFileDialog^ fDialog = gcnew OpenFileDialog;
fDialog->Title = "Open .mc File";
fDialog->Filter = "MC FILES|*.mc";
fDialog->InitialDirectory = "c:\\";
if(fDialog->ShowDialog(thi
s) == System::Windows::Forms::Di
alogResult
::OK){
MessageBox::Show(fDialog->
FileName);
ifs.open((fDialog->FileNam
e)->c_str(
), ifstream::ios_base); //this line gives me an error
while(ifs >> hex >> line){
state.mem[i] = line;
i++;
}
If I use c_str(), it says error C2039: 'c_str' : is not a member of 'System::String'.
If I use ToCharArray() instead, it says error C2664: 'void std::basic_ifstream<_Elem,
_Traits>::
open(const
wchar_t *,std::ios_base::openmode,
int)' : cannot convert parameter 1 from 'cli::array<Type,dimension
> ^' to 'const wchar_t *'
Does anyone know how to do what I want?
Thank you in advance :)
Start Free Trial