I am getting all 10 lines (line by line ) in mfc project as CStringArray but recieve error on to getting 4th line string.
my text file is:
C:\Program Files (x86)\GRETECH\GOMPlayer\GOM.EXE
C:\Program Files\VideoLAN\VLC\vlc.exe
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
C:\Windows\notepad.exe
C:\Windows\System32\cmd.exe
C:\Windows\System32\mspaint.exe
C:\Windows\System32\calc.exe
C:\Windows\System32\calc.exe
C:\Windows\System32\osk.exe
C:\Windows\System32\msconfig.exe
Please check my function or alternate to this function. And please code me fuction for updating any line.
What I have tried:
CString AMyClass::getStringfromText(CString filename, int linenumber)
{
CStdioFile file;
CStringArray aLineArray;
CString All_Lines;
CString out;
CString strExePath;
linenumber=linenumber-1;
CString applicationPath;
char fname[_MAX_PATH+1];
::GetModuleFileNameA(NULL,fname,_MAX_PATH);
applicationPath = fname;
applicationPath.MakeLower();
strExePath = applicationPath.Left(applicationPath.ReverseFind('\\') + 1);
file.Open(strExePath+filename, CFile::modeRead);
while (file.ReadString(All_Lines))
{
aLineArray.Add(All_Lines);
}
file.Close ();
out=aLineArray[linenumber];
return out;
}
**and code is:**
CString str_s4;
str_s4=AMyClass::getStringfromText (_T("MyApps.ini"),4);
AfxMessageBox(str_s4);