Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help regarding DeleteFile(..)

Help regarding DeleteFile(..)

Scheduled Pinned Locked Moved C / C++ / MFC
help
11 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chandu004
    wrote on last edited by
    #1

    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.

    N M 2 Replies Last reply
    0
    • C chandu004

      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.

      N Offline
      N Offline
      Nelek
      wrote on last edited by
      #2

      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

      C 2 Replies Last reply
      0
      • C chandu004

        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.

        M Offline
        M Offline
        Malli_S
        wrote on last edited by
        #3

        What error you're getting ? And be sure to close the file handle you're using...

        -Malli...! :rose:****

        C 1 Reply Last reply
        0
        • N Nelek

          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

          C Offline
          C Offline
          chandu004
          wrote on last edited by
          #4

          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?

          N 1 Reply Last reply
          0
          • N Nelek

            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

            C Offline
            C Offline
            chandu004
            wrote on last edited by
            #5

            and by the way Nelek, could you solve the scroll bar dialog problem? thank you.

            N 1 Reply Last reply
            0
            • M Malli_S

              What error you're getting ? And be sure to close the file handle you're using...

              -Malli...! :rose:****

              C Offline
              C Offline
              chandu004
              wrote on last edited by
              #6

              thanks for your response. it returns 0 and iam sure that iam closing the file.

              1 Reply Last reply
              0
              • C chandu004

                and by the way Nelek, could you solve the scroll bar dialog problem? thank you.

                N Offline
                N Offline
                Nelek
                wrote on last edited by
                #7

                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

                C 1 Reply Last reply
                0
                • C chandu004

                  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?

                  N Offline
                  N Offline
                  Nelek
                  wrote on last edited by
                  #8

                  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

                  C 1 Reply Last reply
                  0
                  • N Nelek

                    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

                    C Offline
                    C Offline
                    chandu004
                    wrote on last edited by
                    #9

                    thanks. i shall wait till weekend.

                    N 1 Reply Last reply
                    0
                    • N Nelek

                      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

                      C Offline
                      C Offline
                      chandu004
                      wrote on last edited by
                      #10

                      even this logic didnot work for me. but this gave me some clue to proceed further. if it works out i shall share the problem and the solution here with you. thanks a lot.

                      1 Reply Last reply
                      0
                      • C chandu004

                        thanks. i shall wait till weekend.

                        N Offline
                        N Offline
                        Nelek
                        wrote on last edited by
                        #11

                        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

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups