0

I have a windows service that uses a FileSystemWatcher to see if there are pdf files moved to a folder, and then, when a user moves a pdf file into that folder, the service executes MyProcess. The pdf filename is like this: name_doctorcode.pdf.
code:

Private static void MyProcess(string pdfname)
{ 
  string sDoctorCode= getdoctorcode(pdfname); //brings doctor code from filename
  bool foundDoctorCode= FindDoctorCode(sDoctorCode); //searchs  into a data container (database, txt,etc..) to see if the doctor code is found
  if(foundDoctorCode==false)
  {
    // HELP to call exe file to prompt user to enter a correct doctorcode
    //pass the doctorcode to a variable
   string sNewDoctorCode = doctorCodeFromExe;
  }
}

Can you help me to do this?
Any guide,tutorial or code?
Thanks

Ebaneo Vk
  • 43
  • 6
  • I think what you are looking for is the [`Process` class](https://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.110).aspx). – Lex Jul 27 '16 at 02:54
  • sorry, but I want to create a way to communicate an exe with my service , soI can get data from the exe and pass the data to the service. thanks – Ebaneo Vk Jul 27 '16 at 02:54
  • That's not really what services are for. The process that puts the file in the location should make sure that the file has a correct code. Having a service that requires input from the user (however indirect) is going down a dark road from which nothing good can come. Your service should log the error, or send an email, SMS message, or whatever, and then just keep on processing. The service should *never* block waiting for user input. – Jim Mischel Jul 27 '16 at 03:25
  • @JimMischel thanks for that advice, so you think that if I do as I wanted, with an exe that prompts user to correct the doctor code, the service will stop? – Ebaneo Vk Jul 27 '16 at 04:02
  • @EbaneoVk: The service will stop while it's waiting for the .exe to return, yes. Unless you code it not to. But then it might start multiple copies of the .exe. In general, what you're proposing isn't a really good idea. – Jim Mischel Jul 27 '16 at 12:40
  • thanks a lot for your help. have a nice day @JimMischel. – Ebaneo Vk Jul 28 '16 at 02:03
  • also thanks for the data @Lex – Ebaneo Vk Jul 28 '16 at 02:03

0 Answers0