cellenbu Posted January 31, 2003 Posted January 31, 2003 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 Quote
*Gurus* divil Posted January 31, 2003 *Gurus* Posted January 31, 2003 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. Quote 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* Nerseus Posted January 31, 2003 *Experts* Posted January 31, 2003 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 Quote "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
WillemM Posted March 2, 2003 Posted March 2, 2003 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.