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. SHFileOperation and win2000

SHFileOperation and win2000

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadmin
5 Posts 4 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.
  • J Offline
    J Offline
    jafrazee
    wrote on last edited by
    #1

    the following code works great on win98 but on win2000 i get the error Cannot Delete File: Cannot read from the source file or disk. The program resides on a network drive and is shared between the 98 and 2000 machine. I have debugged dirname and it is the same on both machines. thank you for any help. wsprintf(dirname,"%s\\%s%s",Td.Dest_Dir,GetSubDir(),"\0"); HANDLE hFind = FindFirstFile(dirname,&FindFileData); if(hFind != INVALID_HANDLE_VALUE && FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY){ SHFILEOPSTRUCT shf; memset(&shf,0,sizeof(shf)); shf.hwnd = selcompany::GetSafeHwnd(); shf.wFunc = FO_DELETE; shf.pFrom = dirname; shf.pTo = "\0\0";//NULL; shf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION; shf.fAnyOperationsAborted = FALSE; shf.hNameMappings = NULL; shf.lpszProgressTitle = " "; if(SHFileOperation(&shf)==0){ //////////////////////clear vars reset window } }else{ ////////////not valid ..... }

    J N M 3 Replies Last reply
    0
    • J jafrazee

      the following code works great on win98 but on win2000 i get the error Cannot Delete File: Cannot read from the source file or disk. The program resides on a network drive and is shared between the 98 and 2000 machine. I have debugged dirname and it is the same on both machines. thank you for any help. wsprintf(dirname,"%s\\%s%s",Td.Dest_Dir,GetSubDir(),"\0"); HANDLE hFind = FindFirstFile(dirname,&FindFileData); if(hFind != INVALID_HANDLE_VALUE && FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY){ SHFILEOPSTRUCT shf; memset(&shf,0,sizeof(shf)); shf.hwnd = selcompany::GetSafeHwnd(); shf.wFunc = FO_DELETE; shf.pFrom = dirname; shf.pTo = "\0\0";//NULL; shf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION; shf.fAnyOperationsAborted = FALSE; shf.hNameMappings = NULL; shf.lpszProgressTitle = " "; if(SHFileOperation(&shf)==0){ //////////////////////clear vars reset window } }else{ ////////////not valid ..... }

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      Forget about it, this anwer was obviously wrong.

      shf.lpszProgressTitle = " ";

      I don't konw if this is the reason of your problem, but I think it should be

      shf.lpszProgressTitle = L" ";

      Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      1 Reply Last reply
      0
      • J jafrazee

        the following code works great on win98 but on win2000 i get the error Cannot Delete File: Cannot read from the source file or disk. The program resides on a network drive and is shared between the 98 and 2000 machine. I have debugged dirname and it is the same on both machines. thank you for any help. wsprintf(dirname,"%s\\%s%s",Td.Dest_Dir,GetSubDir(),"\0"); HANDLE hFind = FindFirstFile(dirname,&FindFileData); if(hFind != INVALID_HANDLE_VALUE && FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY){ SHFILEOPSTRUCT shf; memset(&shf,0,sizeof(shf)); shf.hwnd = selcompany::GetSafeHwnd(); shf.wFunc = FO_DELETE; shf.pFrom = dirname; shf.pTo = "\0\0";//NULL; shf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION; shf.fAnyOperationsAborted = FALSE; shf.hNameMappings = NULL; shf.lpszProgressTitle = " "; if(SHFileOperation(&shf)==0){ //////////////////////clear vars reset window } }else{ ////////////not valid ..... }

        N Offline
        N Offline
        Nish Nishant
        wrote on last edited by
        #3

        Do you have WRITE permissions on the share? Nish


        Check out last week's Code Project posting stats presentation from :- http://www.busterboy.org/codeproject/ Feel free to make your comments.

        1 Reply Last reply
        0
        • J jafrazee

          the following code works great on win98 but on win2000 i get the error Cannot Delete File: Cannot read from the source file or disk. The program resides on a network drive and is shared between the 98 and 2000 machine. I have debugged dirname and it is the same on both machines. thank you for any help. wsprintf(dirname,"%s\\%s%s",Td.Dest_Dir,GetSubDir(),"\0"); HANDLE hFind = FindFirstFile(dirname,&FindFileData); if(hFind != INVALID_HANDLE_VALUE && FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY){ SHFILEOPSTRUCT shf; memset(&shf,0,sizeof(shf)); shf.hwnd = selcompany::GetSafeHwnd(); shf.wFunc = FO_DELETE; shf.pFrom = dirname; shf.pTo = "\0\0";//NULL; shf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION; shf.fAnyOperationsAborted = FALSE; shf.hNameMappings = NULL; shf.lpszProgressTitle = " "; if(SHFileOperation(&shf)==0){ //////////////////////clear vars reset window } }else{ ////////////not valid ..... }

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          You cannot sprintf a null character using %s, because "\0" looks the same as "", which is no characters at all. You'll need to put the extra null char there yourself - I usually zero out the entire buffer beforehand so I don't have to worry about finding the exact end of the string and tacking on an extra 0. --Mike-- Buy me stuff! Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines! My really out-of-date homepage Big fan of Alyson Hannigan and Jamie Salé.

          J 1 Reply Last reply
          0
          • M Michael Dunn

            You cannot sprintf a null character using %s, because "\0" looks the same as "", which is no characters at all. You'll need to put the extra null char there yourself - I usually zero out the entire buffer beforehand so I don't have to worry about finding the exact end of the string and tacking on an extra 0. --Mike-- Buy me stuff! Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines! My really out-of-date homepage Big fan of Alyson Hannigan and Jamie Salé.

            J Offline
            J Offline
            jafrazee
            wrote on last edited by
            #5

            that did it thank you.

            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