Help regarding DeleteFile(..)
-
hai all, here iam facing some problem with deletefile. it goes like this, 1.if i create a file using windows(rightclick>new>text document) and delete it through code then it is working. 2.if i create a file using FILE *fp; and try to delete it, then it is unable to delete it. iam unable to analyse any more on it. please give your ideas and different possibilities to solve the problem. or if any body can suggest any other technique, which works, it would be appreciable.
-
hai all, here iam facing some problem with deletefile. it goes like this, 1.if i create a file using windows(rightclick>new>text document) and delete it through code then it is working. 2.if i create a file using FILE *fp; and try to delete it, then it is unable to delete it. iam unable to analyse any more on it. please give your ideas and different possibilities to solve the problem. or if any body can suggest any other technique, which works, it would be appreciable.
Are you closing the created/opened file before trying to delete it?
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
-
hai all, here iam facing some problem with deletefile. it goes like this, 1.if i create a file using windows(rightclick>new>text document) and delete it through code then it is working. 2.if i create a file using FILE *fp; and try to delete it, then it is unable to delete it. iam unable to analyse any more on it. please give your ideas and different possibilities to solve the problem. or if any body can suggest any other technique, which works, it would be appreciable.
-
Are you closing the created/opened file before trying to delete it?
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
YES iam closing the files(fclose). and more over, the files were created in previous sessions. not in the session where iam trying to delete them. and my files have the extension .cry does it matter? here are some case studies. 1.iam trying to delete the s1.cry(created by my application) like this filename="s1.cry"; DeleteFile(rootpath+"\\cryfiles\\"+filename); RESULT : no use. 2.now i rename it through windows like s1.cry1 and filename="s1.cry1"; DeleteFile(rootpath+"\\cryfiles\\"+filename); RESULT : successful. any ideas?
-
Are you closing the created/opened file before trying to delete it?
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
-
What error you're getting ? And be sure to close the file handle you're using...
-Malli...! :rose:****
-
To be honest... I have not tried more than what I told you. Im in a new project and my time for VC++ is limited. I will take a look this weekend at home. But it actually won't be so easy. I can not simulate your problem, my scrolls are working ok.
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
-
YES iam closing the files(fclose). and more over, the files were created in previous sessions. not in the session where iam trying to delete them. and my files have the extension .cry does it matter? here are some case studies. 1.iam trying to delete the s1.cry(created by my application) like this filename="s1.cry"; DeleteFile(rootpath+"\\cryfiles\\"+filename); RESULT : no use. 2.now i rename it through windows like s1.cry1 and filename="s1.cry1"; DeleteFile(rootpath+"\\cryfiles\\"+filename); RESULT : successful. any ideas?
I make it like follows:
void CMyView::OtherFunction ()
{
char FileName[MAX_PATH];
GetModuleFileName(NULL, FileName, MAX_PATH);
m_szOfflineName = FileName;
m_szOfflineName = m_szOfflineName.Left(m_szOfflineName.ReverseFind('\\'));
m_szOfflineName += "\\OfflinePCode.pc";
}
.
.
void CMyView::OnDestroy()
{ CFormView::OnDestroy();CFile f; //The offline PCode is not needed anymore if (f.Open (m\_szOfflineName, CFile::modeRead)) { f.Close (); f.Remove (m\_szOfflineName); }
}
But I am in MFC, I dont know if u can use the CFile
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
-
To be honest... I have not tried more than what I told you. Im in a new project and my time for VC++ is limited. I will take a look this weekend at home. But it actually won't be so easy. I can not simulate your problem, my scrolls are working ok.
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
-
I make it like follows:
void CMyView::OtherFunction ()
{
char FileName[MAX_PATH];
GetModuleFileName(NULL, FileName, MAX_PATH);
m_szOfflineName = FileName;
m_szOfflineName = m_szOfflineName.Left(m_szOfflineName.ReverseFind('\\'));
m_szOfflineName += "\\OfflinePCode.pc";
}
.
.
void CMyView::OnDestroy()
{ CFormView::OnDestroy();CFile f; //The offline PCode is not needed anymore if (f.Open (m\_szOfflineName, CFile::modeRead)) { f.Close (); f.Remove (m\_szOfflineName); }
}
But I am in MFC, I dont know if u can use the CFile
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
-
If there is more info about the problem than what you already worte in the other post, please send me the relevant codes and a explanation about. You can use the private message if you want.
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson