Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Deleting folders and contents issue

    Scheduled Pinned Locked Moved SDK Help
    1 Posts 0 Posters 114 Views
    Loading More Posts
    • 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.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 06/07/2007 at 14:05, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R8.2-R10 
      Platform:   Windows  ; Mac  ;  Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      A user of my plugin notes that when a file 'thumbs.db' exists in a folder, he can't delete the folder completely from within my plugin. I can only think that either the file is being protected from deletion or that it is not being listed by the BrowseFiles interface.

      Here is the general code being used to delete a folder and all contents (files and subfolders, recursively) :

      // v1.1.7  
      // Delete Folder from Runtime Library  
      //*---------------------------------------------------------------------------*  
      Bool IPPDialog::DeleteFolder()  
      //*---------------------------------------------------------------------------*  
      {  
           // Valid Selection?  
           RuntimeItem*     folder =     root.GetSelectedFolder();  
           if (!folder)     return TRUE;  
           RuntimeItem*     parent =     folder->GetParent();  
           // Only delete below library and sub folders  
           if (folder->IsTypeOf(ITEMTYPE_RUNTIME))     return TRUE;  
           if (parent == folder->GetRuntime())          return TRUE;  
           // Are you sure?  
           if (!QuestionDialog(GeLoadString(IPPS_REMPOSE_YESNO)+"\n\""+folder->GetName()+"\""))     return TRUE;  
           Filename     folderFile =     folder->GetFilename();  
           if (!GeFKill(folderFile, TRUE))  
           {  
                // Are you REALLY sure? (folder is not empty)  
                if (!QuestionDialog(GeLoadString(IPPS_DELFOLDER_REALLY)))     return TRUE;  
                // Backward-Recursively delete subfolders and files in this folder  
                if (!DeleteFolderContents(folderFile))     return FALSE;  
                GeFKill(folderFile, TRUE);  
           }  
           // Update Display  
           root.SetSelected(NULL, SELECTION_NEW);  
           root.Fold(parent, FALSE);  
           root.Fold(parent, TRUE);  
           root.SetSelected(parent, SELECTION_NEW);  
           return TRUE;  
      }  
      // v1.1.7  
      // Delete Folder contents from Runtime Library - recursive  
      //*---------------------------------------------------------------------------*  
      Bool IPPDialog::DeleteFolderContents(const Filename& folder)  
      //*---------------------------------------------------------------------------*  
      {  
           AutoAlloc<BrowseFiles>     browse;  
           if (!browse)     return FALSE;  
           Filename          file;  
           BOOL               isdir;  
      #ifdef     C4D_R10  
           browse->Init(folder, BROWSEFILES_SUPPRESSCACHING);  
      #else  
           browse->Init(folder, FALSE);  
      #endif  
           while (browse->GetNext())  
           {  
                file =     folder+browse->GetFilename();  
                isdir =     browse->IsDir();  
                // Delete Folder's contents  
                if (isdir)  
                {  
                     if (!DeleteFolderContents(file))     return FALSE;  
                }  
                // Delete Folder or File  
                if (!GeFKill(file, isdir))          return FALSE;  
           }  
           return TRUE;  
      }  
      

      Any information on why this occurs and how to work around it is much appreciated!

      Thank you very much,
      Robert

      1 Reply Last reply Reply Quote 0
      • First post
        Last post