realbasic-nug
[Top] [All Lists]

Re: Error 105 on FolderItem.MoveFileTo (again)

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Error 105 on FolderItem.MoveFileTo (again)
From: Tom Benson <tombenson at mac dot com>
Date: Tue, 27 Feb 2007 18:53:10 +1100
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <692BE603-55DD-473D-AE97-FBB029848350 at mac dot com> <603F7C13-109F-4775-9C12-5C91C230186E at mac dot com> <EE6172EE-25D8-44AB-A0C3-352E0D5B1A5E at mac dot com> <32C107A6-9852-4521-9285-E7A62745B088 at mac dot com> <447A7B42-D12B-42DD-AED8-BCEE2D14AFCD at mac dot com>
>
>> If you're comfortable with UNIX, why not just do this???
>>
>> dim s as new shell
>> s.execute "mv "+source.shellpath+" "+dest.shellpath
>
> Because it also has to work on Windows.
>
> And besides, it seems like it *ought* to work. And I'd like to
> understand this. FolderItems are kind of important...

The SHELL example I provided will work fine on Windows too.

But, if you want to understand.

RB brings the item/container metaphor from the Finder/Explorer to  
programming.

Working with folderitems in RB is like performing a programatically  
drag and drop, you need to work within the metaphor rules.

I'll use the desktop folder as a base for a short example, which  
creates a folder on your desktop, creates a file inside it, then  
moves that file out of the newly created folder onto the desktop

dim folder, file as folderitem
dim output as TextOutputStream

folder = DesktopFolder.child("Destination Folder")

//if it doesn't exist, create it
if not folder.exists then f.createAsFolder

//if it does exists, make sure that it is a container (folder or  
directory)
if not folder.directory then
        msgbox "error - cannot create an item inside an item"
else //it exists and it's a folder
        file = folder.child("New File")
        if not file.exists then output = file.createTextFile
        output.write "file contents.txt"
        output.close
        file.moveFileTo DesktopFolder
end

- Tom



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>