Click here to Skip to main content
15,897,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem with creating richeditctrl? Pin
Rolando Cruz19-Jun-07 3:51
Rolando Cruz19-Jun-07 3:51 
QuestionFile reading problem Pin
Y_Kaushik19-Jun-07 3:05
Y_Kaushik19-Jun-07 3:05 
Hello Guru

I am making an application for reading .txt file from Hard Hisk and
copy this file to folder and save it name in database.

In this program i can read data from hard drive and copy the file to
folderConfused | :confused: and also save its name in database.

Whenever i create a file in folder .(Its create successfully but
when try to reading contant of old file and writing new one an
assertion occor.

my code for that function is below.

CString str;
int ids;
CFileDialog Obj(TRUE);
if(Obj.DoModal() ==IDC_BUTTON3)
{
m_Upload = Obj.GetFileName();
}
str.Empty();
str = Obj.GetPathName();
SetDlgItemText(IDC_EDIT1,str);
///////////////////////////////////////////////////////////////////
/* reading file data from disk */
/////////////////////////////////////////////////////////////////
CString strLine = "";
CString buffer = "";
CStdioFile fileObj,filewrite;
CString fname;


fileObj.Open(str, CFile::modeRead | CFile::shareDenyWrite);

fname = fileObj.GetFileName();
// MessageBox(fname);


while(fileObj.ReadString(strLine))
{
fileObj.ReadString(strLine);
// fileObj.WriteString(fname);
buffer += strLine + "\r\n";
}
fileObj.Close();
// MessageBox(buffer);
SetDlgItemText(IDC_EDIT3,buffer);

fileObj.Open("c:\\UserFolder\\" + fname + ".txt",CFile::modeCreate,NULL);

Its run up to here successfully.

Its create a blank file in folder .


Now i am writing above code like this ( simple reading data from old file and writing it to new one an assertion occor . The code is below.


CString str;
int ids;
CFileDialog Obj(TRUE);
if(Obj.DoModal() ==IDC_BUTTON3)
{
m_Upload = Obj.GetFileName();
}
str.Empty();
str = Obj.GetPathName();
SetDlgItemText(IDC_EDIT1,str);
///////////////////////////////////////////////////////////////////
/* reading file data from disk */
/////////////////////////////////////////////////////////////////
CString strLine = "";
CString buffer = "";
CStdioFile fileObj,filewrite;
CString fname;


fileObj.Open(str, CFile::modeRead | CFile::shareDenyWrite);

fname = fileObj.GetFileName();
// MessageBox(fname);


while(fileObj.ReadString(strLine))
{
fileObj.ReadString(strLine);
// fileObj.WriteString(fname);
buffer += strLine + "\r\n";
}
fileObj.Close();
// MessageBox(buffer);
SetDlgItemText(IDC_EDIT3,buffer);

/*//////////////////////Copying file to another folder//////////////////////////*/
str.Empty();
fileObj.Open(str,CFile::modeRead);

while(filewrite.ReadString(strLine))
{

filewrite.WriteString(fname);
buffer += strLine + "\r\n";
}

fileObj.Open("c:\\UserFolder\\" + fname + ".txt",CFile::modeCreate,NULL);

How can i write content of old one to new one.

Any one Please told me .











Regard's
Kaushik

AnswerRe: File reading problem Pin
Rolando Cruz19-Jun-07 3:38
Rolando Cruz19-Jun-07 3:38 
AnswerRe: File reading problem Pin
Iain Clarke, Warrior Programmer19-Jun-07 4:08
Iain Clarke, Warrior Programmer19-Jun-07 4:08 
QuestionCOM/DCOM is now what? Pin
Rolando Cruz19-Jun-07 2:11
Rolando Cruz19-Jun-07 2:11 
AnswerRe: COM/DCOM is now what? Pin
bob1697219-Jun-07 4:34
bob1697219-Jun-07 4:34 
GeneralRe: COM/DCOM is now what? Pin
Rolando Cruz19-Jun-07 5:08
Rolando Cruz19-Jun-07 5:08 
AnswerRe: COM/DCOM is now what? Pin
James R. Twine19-Jun-07 4:51
James R. Twine19-Jun-07 4:51 
AnswerRe: COM/DCOM is now what? Pin
Rolando Cruz19-Jun-07 5:14
Rolando Cruz19-Jun-07 5:14 
GeneralRe: COM/DCOM is now what? Pin
Matthew Faithfull19-Jun-07 7:51
Matthew Faithfull19-Jun-07 7:51 
GeneralRe: COM/DCOM is now what? Pin
Rolando Cruz19-Jun-07 7:56
Rolando Cruz19-Jun-07 7:56 
QuestionUnable to launch dialog box Pin
Wamuti19-Jun-07 2:09
Wamuti19-Jun-07 2:09 
AnswerRe: Unable to launch dialog box Pin
Roger Stoltz19-Jun-07 2:40
Roger Stoltz19-Jun-07 2:40 
GeneralRe: Unable to launch dialog box Pin
Wamuti19-Jun-07 3:09
Wamuti19-Jun-07 3:09 
GeneralRe: Unable to launch dialog box Pin
Wamuti19-Jun-07 3:17
Wamuti19-Jun-07 3:17 
QuestionHow to: Structure initialization Pin
Programm3r19-Jun-07 0:01
Programm3r19-Jun-07 0:01 
AnswerRe: How to: Structure initialization Pin
Rage19-Jun-07 0:27
professionalRage19-Jun-07 0:27 
GeneralRe: How to: Structure initialization Pin
Programm3r19-Jun-07 0:47
Programm3r19-Jun-07 0:47 
QuestionDifference between DLL & Process ??? Pin
amitmistry_petlad 18-Jun-07 23:45
amitmistry_petlad 18-Jun-07 23:45 
AnswerRe: Difference between DLL & Process ??? Pin
Programm3r19-Jun-07 0:05
Programm3r19-Jun-07 0:05 
AnswerRe: Difference between DLL & Process ??? Pin
karle19-Jun-07 0:08
karle19-Jun-07 0:08 
QuestionWhy can't it show a whole bitmap in listctrl in icon form Pin
Chen-XuNuo18-Jun-07 23:32
Chen-XuNuo18-Jun-07 23:32 
AnswerRe: Why can't it show a whole bitmap in listctrl in icon form Pin
Rage18-Jun-07 23:42
professionalRage18-Jun-07 23:42 
GeneralRe: Why can't it show a whole bitmap in listctrl in icon form Pin
Chen-XuNuo18-Jun-07 23:49
Chen-XuNuo18-Jun-07 23:49 
GeneralRe: Why can't it show a whole bitmap in listctrl in icon form Pin
Rage19-Jun-07 0:22
professionalRage19-Jun-07 0:22 

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.