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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use FileSystemWatcher

string path;
FileSystemWatcher watcher = new FileSystemWatcher(path, "*.PS");
//subscribe to watcher.Created event

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
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.
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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?
And yes, that filter will match only *.PS files events.

Creating windows services:

and specially for you, service + watcher :)
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
samelaminAuthor Commented:
brilliant thanks guys
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.