FTP File In Use / VB.NET

  • Thread starter Thread starter iforsyth
  • Start date Start date
I

iforsyth

I have an application that sweeps through directories and looks for
FTP'd files to copy to a server location. Is there a good way to
detect whether a file is currently in use, e.g. someone is remotely
FTP'ing the data to the directory that the application sweeps?
 
Hi,

Thanks for posting in the community.

Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
Hi,

Thanks for posting in the community.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you are sweeping a folder on local
machine and the folder will be an ftp directory, that is to say, other
person will remotely upload file to this directory.
You wants to know if some of the files are in use.(e.g. a file is being
uploaded and it did not complete when you are scanning the directory)
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think you may try to open the file which you wants to detect as
FileShare.None, if you get exception and parse the error message, we will
know that the file is being used by another process.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Try
File.Open("C:\Inetpub\ftproot\Win03.GHO", FileMode.Open,
FileAccess.ReadWrite, FileShare.None)
Catch ex As Exception
MsgBox(ex.Message())
End Try
End Sub

Please apply my suggestion above and let me know if it helps resolve your
problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Peter,

Does the file open generate an error on an open when someone is
uploading the file to the directory and it's in the middle of being
transferred via FTP?

Thanks,

Ian
 
Hi Lan,

Thanks for your quickly reply!

The method will tell you that the file is being used by another process.
But it will not tell us detailed information about FTP server info, e.g. if
it is being uploaded by someone.

I think this should be specified to one ftp server to see if it has provide
the programming interface which helps us to retrieve the related
information.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Lan,

Thanks for posting in the community.

Did you have any concern on this issue, if so please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Peter
I have been watching the thread with interest. I wonder if there is
something you can do if the FTP server is NOT local?
Thank you
 
Back
Top