writing a watched folder

hey All

this question has been bothering me for quite some tiime, im in the process of learning about printers and port monitiors and i am trying to print across networks

now the ideal solution would be that a client would have a virtual printer installed with a custom port and when the end user prints to this printer the document is sent (or better yet uploaded) to the server

now I also started playing about with RedMon which is essentially a port monitor that redirects an output to a program, so if you print to a document that has the RedMon port set a postscript file is created (*.PS) it then uses GhostScript to convert this file to pdf

I was thinking if I have the pdf I can then upload it to the server using an upload application that i already have running on the server, given the path uploading is very simple.

The question now is can i create a program or a watch folder that calls a program everytime redmon creates a ps file, and this program would run ghostscript to convert the postscript file to PDF then take the path and send the parameters to a web application that would upload the document


 
samelaminAsked:
Who is Participating?
 
lazyberezovskyConnect With a Mentor Commented:
Use FileSystemWatcher

string path;
FileSystemWatcher watcher = new FileSystemWatcher(path, "*.PS");
//subscribe to watcher.Created event
0
 
samelaminAuthor Commented:
yes but the thing is i dont know the name of the document being created
or will it watch out for all documents with the format *.ps?

because in realiy all im doing is watching for the creatig of a .ps file to trigger conversion, if its too difficul to accomplish then just a trigger when a ps file is created to give the path to a asp.net app which will upload the document
0
 
SriVaddadiConnect With a Mentor Commented:
Create a windows service and in that windows service use FileSystemWatcher object (as my buddy said above) to get notification of file creation and then you could launch your program to complete the task

Note that you would not be able to launch an application with UI from windows service.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
samelaminAuthor Commented:
its fine i dont need a user interface i just need to pass the path to a website
so what your saying is that i need to write my own windows service?

how do i go about doing that? I am using visual studio 2008 so what sort of project is that?
0
 
lazyberezovskyConnect With a Mentor Commented:
And yes, that filter will match only *.PS files events.

Creating windows services:
http://www.codeproject.com/KB/system/WindowsService.aspx

and specially for you, service + watcher :)
http://www.beansoftware.com/NET-Tutorials/Create-Windows-Services.aspx
0
 
SriVaddadiConnect With a Mentor Commented:
You have windows service project template. New Project and select windows service project. You would get the Service1.cs generated for you. Take a look at it. It is intuitive. Just in case if you have trouble feel free to post back
0
 
samelaminAuthor Commented:
brilliant thanks guys
0
All Courses

From novice to tech pro — start learning today.