SteveoAtilla Posted April 7, 2005 Posted April 7, 2005 Hello all! I have an ASP page with VB.NET codebehind pages that needs to watch for a specific file to exist in a specific locaiton on the web server. Here is the sequence of events: The user causes a file to be created on the server Software on the server will then pick up that text file and create a PDF from it (PlanetPress software - nice stuff) The PDF is written to a different folder in the website What I need to do is, after the text file is created, I need to watch the output folder for a specific file name. I obviously can't user a timer, so how do I watch a folder for a file? I'd hate to simply loop. What a waste of resource.... Thanks, Kahuna Quote The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order. Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing. -- Vincent T. Lombardi
kahlua001 Posted April 7, 2005 Posted April 7, 2005 Do you have control over your PDF software, perhaps upon successfuly creation of the PDF file, raise an event or write to a db. Quote
SteveoAtilla Posted April 7, 2005 Author Posted April 7, 2005 Do you have control over your PDF software' date=' perhaps upon successfuly creation of the PDF file, raise an event or write to a db.[/quote'] I don't know about raising an event, but even if it were to write to a DB (the majority of this website interacts with a large SQL database), I would still need to watch that, wouldn't I? Quote The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order. Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing. -- Vincent T. Lombardi
Leaders snarfblam Posted April 7, 2005 Leaders Posted April 7, 2005 Would it be possible to use the System.IO.FileSystemWatcher class? Quote [sIGPIC]e[/sIGPIC]
SteveoAtilla Posted April 7, 2005 Author Posted April 7, 2005 Would it be possible to use the System.IO.FileSystemWatcher class? I'm playing with that right now, but it seems to be acting the same as the Timer. As soon as the page loads, there is no longer a connection to the server, so it never sees the file being created. Is the FileSystemWatcher valid in this context? Quote The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order. Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing. -- Vincent T. Lombardi
Mister E Posted April 7, 2005 Posted April 7, 2005 You can't use it in an ASP.NET page. The web is stateless. The instances of "code behind" classes are constructed and then destructed almost immediately. Furthermore there are no persistently running processes in the web application itself. The best solution to your problem would be to use the FileSystemWatcher in a Windows Service application. 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.