Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am now in the process of rewriting mountains of ASP classic stuff. I have one page that accesses a file that is FTP'd up every 5 minutes. Sometimes the file is in the process of being FTP'd when the ASP page tries to access it. This results in an empty file.

 

I'm hoping that in VB.net, there is a way to detect whether the file is being FTP'd or not.

 

Thank you for your time,

Chris

  • *Gurus*
Posted

I don't honestly think there is one. What you can do depends on how the FTP server has the file opened. It might me that you can open the file and check for a length of 0, or you could try opening the file for write and trap an exception, that ought to work.

 

Alternatively, I found this solution which uses the OpenFile to ascertain if a file is opened by another process or not. You'd have to port from VB6 calling API, to VB.NET but it might be an answer.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

  • *Experts*
Posted

If you can provide a simple web server then the clients could call a simple webservice to notify your process that a file has arrived.

 

Also, you could require that each client uploads a small "alldone.txt" type of file after the main file. Your process could then check for the existence of the dummy file to indicate the first one is finished. This works well if each client has their own directory they upload to or a standard naming convention for their uploads.

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • 1 month later...
Posted

I use this:

 

  Dim fl as New System.IO.Filestream(filetowrite,FileMode.OpenOrCreate,FileAccess.Write,FileShare.None)

 

this locks the file so that no other client can read or write the file. But you can also use FileShare.Read instead, this will share the file for reading only, so that the client can continue to read the file when it's being rewritten.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...