0

It is possible to use File.WriteAllText in the windows service ?? now how to add them to the timer for checking every minute, I'd like to write text to a file, but unfortunately it did not work ..

void _zegar_timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (!checkSom)
            {
                checkSom= true;
                if (add.SprAkt)
                {
                    Process[] proces = Process.GetProcessesByName("Obs WS");
                    int licznik = proces.Count();

                    if (licznik == 0)
                    {
                        string sciezka = Path.Combine(Environment.CurrentDirectory, "ObsWS.exe");
                        ProcessExtensions.StartProcessAsCurrentUser(sciezka);
                    File.WriteAllText(Path.Combine(Environment.CurrentDirectory, "test.txt"), "Running ok");
                    }
                }

                checkSom= false;
            }     
        }

Maybe I need put this all code in another class and not put in primary windows service or maybe put this in new dll and add this dll and then use method?

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
mariusz695
  • 47
  • 6
  • correct all code (i cant edit primary post): http://pastebin.com/3GN3QCGh – mariusz695 Dec 26 '15 at 01:41
  • Problem solved, could not save my file, because as I use Environment.CurrentDirectory and then was in the service, and the service as I see launches in the system32 and, therefore, see no problem and there was a problem :) – mariusz695 Dec 26 '15 at 13:24

0 Answers0