Re: FileCopy vs. Read & Write or CopyFile API

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Jialiang Ge [MSFT] wrote:
Hello Peter,

From your post, my understanding on this issue is: you wonder how to synchronize a document in server to its client with VB FileCopy function. If I'm off base, please feel free to let me know.

Generally speaking, VB function FileCopy fails and pop out "Permission denied" exception when we attempt to copy a file that is opened or when the destination file cannot be overwritten. Please check if the document in the server is opened, and if the destination in client can be overwritten.

<snip>

Another approach is to use FileSystemObject (http://msdn2.microsoft.com/en-us/library/2z9ffy99.aspx) , which can copy a locked file:
Set fs = CreateObject("Scripting.FileSystemObject")
fs.copyfile "server file", "client file"

It copies the last save of the file.
Please have a try and let me know the result.

<snip>

Your suggestion about using the FileSystemObject is quite interesting. Where did your read that it also can copy locked files?
Personally I hate the FSO (as it contains some nasty bugs and it results in another - for me useless - dependency) but if you can put me in the right direction, I'll consider it again.
Probably it's also possible using the Win32 API's (as FSO is a wrapper around it). I hope the source you've used to state this mentions it.

Sinna
.



Relevant Pages

  • Re: Send and recive files
    ... After my asp page have readed this file, I have to send a response file to the client. ... I have to read a Chunk of file with FSO and send this Chunk to a client? ... Normally the server provides HTML ...
    (microsoft.public.inetserver.asp.general)
  • Re: MoveFile on network
    ... To move the file to only one client I did the following: ... Open the source file on the server with option CFile:ShareExclusiv to ... could write his own move routine that copies the locked file. ... I heard that on operating system level the MoveFile() function used ...
    (microsoft.public.vc.mfc)
  • Re: MoveFile on network
    ... To move the file to only one client I did the following: ... Open the source file on the server with option CFile:ShareExclusiv to ... could write his own move routine that copies the locked file. ... I heard that on operating system level the MoveFile() function used ...
    (microsoft.public.vc.mfc)
  • Re: file system management
    ... Can something be written to read using fso the filesystem on the ... Present it to the client allow drag and drop then post back to the ... server and have the server implement the changes?? ...
    (microsoft.public.dotnet.framework.aspnet)
  • What is easiest way to save a file to a users / client computer
    ... I have a text file that I want users to download via a web page. ... on the users / client file system. ... seem to get FSO to open the file on the server. ... Does anyone know can FSO ...
    (microsoft.public.dotnet.framework.aspnet)