New topic: Recursively deleting files
<http://forums.realsoftware.com/viewtopic.php?t=29238> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message rbasic20091005153 Post subject: Recursively deleting filesPosted: Sun Jul 26, 2009 12:40 pm Joined: Sat Apr 04, 2009 5:10 pm Posts: 162 Hola, My application is supposed to let users pick files and folders, make a temporary folder to hold them and then create a disc image. The process is complete except that my app is not able to delete the temporary folder. I initially wrote the following. Code:// Finally, delete the folder... Dim iDel,delNum As Integer Dim delFolder As FolderItem If WindowC.iGet.Exists Then delFolder = GetFolderItem(WindowC.iGet.AbsolutePath) delNum = delFolder.Count For iDel = delNum To 1 Step -1 delFolder.Item(iDel).Delete Next WindowC.iGet.Delete End if I realized that the code above will not going into subdirectories to delete files. After searching this discussion board, I've found a nice, simple example code submitted by shayaan.siddiqui here. If I adopt it, I have Code:DeleteFilesFromFolder(delFolder) and Code:Dim i, fCount as Integer fCount=Folder.Count For i = fCount Downto 1 If Folder.TrueItem(i) <> Nil Then If Folder.TrueItem(i).Directory Then DeleteFilesFromFolder(Folder.TrueItem(i)) End If Folder.TrueItem(i).Delete End If Next i Umm... It seems that there is always one folder left out when the app goes through the method above. I cannot figure out how to make it better. Hopefully, experienced Basic programmers can. Thank you for your advice. Tom _________________ Mac OS X 10.5.6/REALBasic 2008 R4 I say 'no' to MBS plug-ins. I boycott them. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
