New topic: Moving/copying a folder fails because of access denied
<http://forums.realsoftware.com/viewtopic.php?t=23215> Page 1 of 1 [ 4 posts ] Previous topic | Next topic Author Message benjy355 Post subject: Moving/copying a folder fails because of access deniedPosted: Wed Jul 02, 2008 6:16 pm Joined: Tue Nov 29, 2005 11:30 pm Posts: 307 Location: BC, Canada Edit: I can move single files, but not folders? [/edit] I'm not sure why this is happening, I can move it around using Windows Explorer, but my program can't do shit-all Dim f As FolderItem Dim i As Integer Dim doHalt As Boolean = False Dim addonFolder As FolderItem Dim d As New SelectFolderDialog f = d.ShowModal addonFolder = App.SteamDir.Child("steamapps").Child(App.UserAccount).Child("garrysmod").Child("garrysmod").Child("addons") //This isn't nil. If f <> nil Then If addonFolder = nil Or Not addonFolder.Exists Then //We see that here :D i = MsgBox("Woahh! Addons folder not found, create?", 52, "Caution!") If i = 6 Then addonFolder.CreateAsFolder Else doHalt = True End If End If If Not doHalt Then f.MoveFileTo addonFolder //Move it. If f.LastErrorCode > 0 Then //Did it fail? MsgBox str(f.LastErrorCode) //Gives me 102 :( End if Thread1.Run //Does stuff with the folder this folder is going into. MsgBox "Addon Installed!" End If End If Am I doing something wrong? _________________ Windows Vista Ultimate 64x + REALBasic 2008r2/2007r4 Last edited by benjy355 on Wed Jul 02, 2008 8:06 pm, edited 1 time in total. Top harriew Post subject: Re: Moving/copying a folder fails because of access deniedPosted: Wed Jul 02, 2008 8:03 pm Joined: Fri Dec 01, 2006 3:09 pm Posts: 618 Location: Tennessee, USA I won't bet my paycheck on this answer; but, I don't believe that you can use MoveFIleTo or CoyFileTo to move or copy a folder and all of its contents in one command like you are trying. I believe that what you have to do is see if a folder by the same name exists in the final location and if not first create the folder and then copy or move the individual files. I know the language reference says that moves/copies the folderitem and in your case the folderitem is a folder but I do not believe it works that way. The windows explorer is written to handle such cases. They properly named the commands with the word File within them but I think they should give a little better explanation in the reference manual. It's just like you cannot do a FolderItem.Delete on a folder, you first have to delete all of the files within the folder and then delete the empty folder. However, as I said in the very beginning, I won't bet my paycheck on being correct here. Few bucks but not the whole thing. z Top benjy355 Post subject: Re: Moving/copying a folder fails because of access deniedPosted: Wed Jul 02, 2008 8:09 pm Joined: Tue Nov 29, 2005 11:30 pm Posts: 307 Location: BC, Canada Oh sweet Jesus that's a lot of file-digging to move that beast... T_T ..What the hell, I tried to use cmd to move it and it gave me the same error. Quote:C:\Users\*>MOVE /Y C:\Users\benjam~1\desktop\achiev~1 D:\progra~1\Steam\Steama~1\theben~1\GARRYS~1\garrys~1\addons Access is denied. Edit: You were right, problem solved though, I found a recursive example in the language reference. A bit of editing and I got it to do what I wanted. Sub CopyFileorFolder (source as FolderItem, destination as FolderItem) Dim i as Integer Dim newFolder as FolderItem If source.directory then //it's a folder newFolder=destination.child(source.name) newFolder.createAsFolder For i=1 to source.count //go through each item If source.item(i).directory then //it's a folder CopyFileOrFolder source.item(i), newFolder //recursively call this //routine passing it the folder else source.item(i).CopyFileTo newFolder //it's a file so copy it end if next else //it's not a folder source.CopyFileTo destination end if end sub _________________ Windows Vista Ultimate 64x + REALBasic 2008r2/2007r4 Top HardyMachia Post subject: Re: Moving/copying a folder fails because of access deniedPosted: Wed Dec 26, 2012 3:21 pm Joined: Mon Dec 11, 2006 12:25 pm Posts: 66 So what you are saying is FolderItem.MoveFileTo doesn't work for folders? Shouldn't this be documented? I'm definitely having issues with FolderItem.MoveFileTo under Windows moving a folder from C: to D:. I'll try the manual moving as a work around to see if that solves the issue, but then I'll file a bug. _________________ http://www.catamount.com PocketMoney for iOS, OSX, Linux, Windows, and Android Realbasic developer chat ##rb on irc.freenode.net Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 4 posts ] -- 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]
