I have a simple C++ GUI base program that select the file using OpenFileDialog property. I need to get the file path and then I need to use that file path to read the text file line by line using getline(). But it gives an error when I replace the ifstream variable value as OpenFileDialog value. My code is attached below.
I want to replace
ifstream myfile("C:/Users/Shenal/Desktop/source.vandii");
with
ifstream myfile(strfilename);
The code is down below.
my form1.h file
Stream^ mystream;
OpenFileDialog^ OpenFileDialog1 = gcnew OpenFileDialog;
String^ strfilename = OpenFileDialog1->InitialDirectory + OpenFileDialog1->FileName;
String^ Readfile = File::ReadAllText(strfilename);
//MessageBox::Show(Readfile);
string line;
ifstream myfile("C:/Users/Shenal/Desktop/source.vandii");
ofstream compiledFile;
vector<string> filecontent;
if (myfile.is_open())
{
    MessageBox::Show(Readfile);
    while (!myfile.eof())
    {
        getline(myfile, line);
    }
}
 
    