realbasic-nug
[Top] [All Lists]

Re: Temp File Rename fails

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Temp File Rename fails
From: Thomas Reed <tareed at bitjuggler dot com>
Date: Mon, 31 May 2004 09:04:50 -0400
Delivered-to: realbasic-nug at lists dot realsoftware dot com
List-help: <mailto:realbasic-nug-request@lists.realsoftware.com?subject=help>
List-id: REALbasic NUG <realbasic-nug.lists.realsoftware.com>
List-post: <mailto:realbasic-nug@lists.realsoftware.com>
References: <F442DB0E-B2B7-11D8-9EB8-000393B29272 at gatorgraphics dot com> <a06010229bce0cbd76227 at [10 dot 0 dot 1 dot 2]> <7BD1350B-B301-11D8-94B2-000393B29272 at gatorgraphics dot com>
I noticed that the docs say a temporary file can't be renamed.

I think that must be an error in the docs or a misreading of them. I can't find it, though, where does it say this?
In the online LR under the description of the name property. "It will rename files if the user has permission to rename them, they are not in use, and it's not a folder or temporary file."

I think that's an error. In fact, I know it, because I rename temp files, and I just ran a test that successfully renamed a folder.

f.MoveFileTo tFile    //This works fine
tFile.Name = aRequest.filenames(i) //THIS FAILS TO RENAME ends up with name like Temp-1234

Well, that makes sense. You've moved the file, but tFile is still pointing to a file with a particular name in the temporary folder.

I've found that I can make it work if I start with a new folderitem and get the Temp-1234 file by using child with the name

f.MoveFileTo tFile     //Again works fine
f2 = tFile.child(f.name)   //get new folderitem reference to temp file
f2.Name = aRequest.filenames(i)   //This now works???

Makes sense.  Now f2 points to the file in its new location.

You could actually do something like this, IIRC:

  newFile = f.Child(aRequest.filenames(i))
  newFile.MoveFileTo tFile

I could be wrong about that, but I thought I remembered there was some way to have MoveFileTo do a rename at the same time.
--

-Thomas

Personal web page:                  <http://homepage.mac.com/thomasareed/>
My shareware:                                 <http://www.bitjuggler.com/>
Free REALbasic code:                    <http://www.bitjuggler.com/extra/>

There are 10 kinds of people in the world -- those who understand binary
numbers and those who don't.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

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