Click here to Skip to main content
15,898,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: file closing after reading Pin
Rajkumar R30-Jan-08 0:19
Rajkumar R30-Jan-08 0:19 
GeneralRe: file closing after reading Pin
Cedric Moonen30-Jan-08 0:49
Cedric Moonen30-Jan-08 0:49 
GeneralRe: file closing after reading Pin
Cedric Moonen29-Jan-08 23:23
Cedric Moonen29-Jan-08 23:23 
Questionworking with CFile? Pin
rowdy_vc++29-Jan-08 22:27
rowdy_vc++29-Jan-08 22:27 
AnswerRe: working with CFile? Pin
Maxwell Chen29-Jan-08 22:31
Maxwell Chen29-Jan-08 22:31 
AnswerMessage Closed Pin
29-Jan-08 22:38
professionalRajesh R Subramanian29-Jan-08 22:38 
GeneralRe: working with CFile? Pin
rowdy_vc++29-Jan-08 22:43
rowdy_vc++29-Jan-08 22:43 
GeneralRe: working with CFile? Pin
Rajesh R Subramanian29-Jan-08 22:48
professionalRajesh R Subramanian29-Jan-08 22:48 
  CStdioFile csf;
CFileException cfe;
CString str, sTemp;
CStringArray csa;
int iSize=0, iVer=0;


if ( !csf.Open(_T("E:\\Some.txt"), CFile::modeReadWrite, &cfe) )
    AfxMessageBox(_T("Failed to open the file"));

while(csf.ReadString(str))
{
    sTemp = str;
    str.Format(_T("%d. %s"), iVer+1, sTemp);
    csa.Add(str);
    ++iVer;
}

csf.SeekToBegin();
iSize = csa.GetSize();

for(int i=1; i<=iSize; ++i)
{
    sTemp.Format(_T("%s\n"), csa.GetAt(i-1));
    csf.WriteString(sTemp);
}
csf.Close();

1. Copy paste the above code into your project.
2. Change the path of the file name.
3. Compile and run.
4. I pity your employer.

Seriously, if you are not good at something, you should not take that as your profession.


Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP

GeneralRe: working with CFile? Pin
rowdy_vc++29-Jan-08 22:52
rowdy_vc++29-Jan-08 22:52 
GeneralRe: working with CFile? Pin
Rajesh R Subramanian29-Jan-08 23:08
professionalRajesh R Subramanian29-Jan-08 23:08 
GeneralRe: working with CFile? Pin
Rajesh R Subramanian29-Jan-08 22:58
professionalRajesh R Subramanian29-Jan-08 22:58 
GeneralRe: working with CFile? Pin
rowdy_vc++29-Jan-08 23:02
rowdy_vc++29-Jan-08 23:02 
GeneralRe: working with CFile? Pin
CPallini29-Jan-08 23:05
mveCPallini29-Jan-08 23:05 
GeneralRe: working with CFile? Pin
rowdy_vc++29-Jan-08 23:14
rowdy_vc++29-Jan-08 23:14 
GeneralRe: working with CFile? [modified] Pin
CPallini29-Jan-08 23:26
mveCPallini29-Jan-08 23:26 
GeneralRe: working with CFile? Pin
Cedric Moonen29-Jan-08 23:35
Cedric Moonen29-Jan-08 23:35 
GeneralThanks Pin
CPallini29-Jan-08 23:42
mveCPallini29-Jan-08 23:42 
GeneralRe: working with CFile? Pin
vijay_aroli29-Jan-08 23:27
vijay_aroli29-Jan-08 23:27 
NewsRe: working with CFile? Pin
Rajkumar R29-Jan-08 23:26
Rajkumar R29-Jan-08 23:26 
GeneralRe: working with CFile? Pin
David Crow30-Jan-08 3:38
David Crow30-Jan-08 3:38 
AnswerOh No... Not again!!! Pin
vijay_aroli29-Jan-08 23:16
vijay_aroli29-Jan-08 23:16 
GeneralRe: Oh No... Not again!!! Pin
rowdy_vc++29-Jan-08 23:26
rowdy_vc++29-Jan-08 23:26 
GeneralRe: Oh No... Not again!!! Pin
vijay_aroli29-Jan-08 23:35
vijay_aroli29-Jan-08 23:35 
GeneralRe: Oh No... Not again!!! Pin
Cranky29-Jan-08 23:53
Cranky29-Jan-08 23:53 
GeneralTo remove the data from a file. Pin
Chandrasekharan P29-Jan-08 20:45
Chandrasekharan P29-Jan-08 20:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.