File.WriteAllText in windows service

214 views Asked by At

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?

0

There are 0 answers