Re: Writing to a file
Re: Writing to a file
- Subject: Re: Writing to a file
- From: JP Kelly <email@hidden>
- Date: Sun, 14 Jul 2002 11:20:09 -0700
On 7/14/02 10:21 AM, "Paul Berkowitz" <email@hidden> wrote:
>
On 7/14/02 9:57 AM, "JP Kelly" <email@hidden> wrote:
>
>
>>> I am trying to write to a file that already exists.
>
>>> Here is the offending line:
>
>>>
>
>>> set fileRef to (open for access file "Users:jpkelly:Library:Application
>
>>> Support:mover.prefs" with write permission)
>
>>>
>
>>> This gives me an error: "Finder got an error: Duplicate file name."
>
>>>
>
>
All this is because you still have open files from your previous failures
>
when your script quit. _You_ may know you moved them to the trash, but the
>
file system still sees them in their original location because the files
>
were never closed.
>
>
If you log out and in, everything will work OK. And in future, it's a good
>
idea to always include this error trap:
>
>
try
>
set fileRef to (open for access file "whatever" with write permission)
>
-- do your stuff
>
close access fileRef
>
on error
>
close access fileRef
>
end try
>
Yep that helped. Surprise when I tried to empty the trash!
So now I am using "try" and "on error" to "close access fileRef"
But...
I still get an error when I try to open the file once it has been created by
"set fileRef to (open for access file "whatever" with write permission)"
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.