On 8/12/06, William Squires <[EMAIL PROTECTED]> wrote:
Could another user/process have the file open for exclusive read/
write or write-only access?

Not in this case. And once I changed my method to set the
binarystream's position to 0 before writing, the operation worked
correctly, even though the FolderItem's LastError property in the
debugger was still changing to 102.

However, the 'can't-copy-to-an-Integer' sounds like a bug - I'd
report it.

Yeah, I have a couple of things I need to do reports for now.

On Aug 12, 2006, at 3:40 PM, Dennis Birch wrote:

> I've run into some problems with a chunk of code that seems like it
> should work without any issues. I'm hoping somebody can look at it and
> tell me what's I'm doing wrong.
>
> One thing I'm experiencing is an inability to copy a
> FolderItem.LastErrorCode to a local Integer variable. You'll see in
> the code below several places where I try to do that, but the value of
> n is always 0, even though showing the contents of "f" reveals an
> error code of 102 after the line "bs.Write s".
>
> The error code 102 indicates "Access denied" according to the online
> reference. I have checked in the Finder's Get Info box, and I have
> Read and Write permissions for both the folder containing the files
> I'm looping over, and the folder that contains them. So that error
> makes no sense to me.
>
> I have added a couple of comments to the code below in case anybody
> wants to plug it into a project and test it. (You'll need to provide
> the function a FolderItem for a folder you want to work on.) The
> comments are warnings that as written, this code will truncate the
> contents of your files, so don't use it on anything that matters to
> you.
>
> But please do let me know if you can see anything I'm doing wrong
> here.
>
> By the way, this is in RB 2006R3 with Mac OS X 10.4.7.
>
>
> Private Sub Work(SrcFolder As FolderItem)
>  dim i, u As Integer
>  dim n As Integer
>  dim s As String
>  dim bs As BinaryStream
>  dim f As FolderItem
>
>  dim errors As Integer
>
>  // WARNING: RUN THIS CODE ONLY ON A COPY OF A FOLDER --
>  // IT WILL ALTER THE CONTENTS OF THE FILES IN THE FOLDER
>
>  u = SrcFolder.Count
>
>  for i = 1 to u
>    f = SrcFolder.Item(i)
>
>    bs = f.OpenAsBinaryFile(True)
>    n = f.LastErrorCode
>
>    if bs <> nil Then
>      n = f.LastErrorCode
>
>      s = bs.Read(bs.Length, Encodings.UTF8)
>      n = f.LastErrorCode
>
>      // the value of "s" may be changed in the actual code
>      s = "This is a test, this is a test."
>      // WARNING: LEAVING THE ABOVE LINE INTACT WILL TRUNCATE THE
> CONTENTS OF EVERY FILE IN YOUR
>      // FOLDER TO THE LENGTH OF THE ABOVE STRING
>
>      bs.Write s
>      n = f.LastErrorCode
>
>      if n <> 0 Then errors = errors + 1
>
>      bs.Length = lenb(s)
>
>    end if
>  next
>
>
>  MsgBox "Errors: " + str(errors)
> End Sub
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

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

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

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

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

Reply via email to