0

I've created a File Watcher Service to monitor, and log all changes on the computer, and write them to a file on C:/, but I want to be able to send that file on close (Shutdown of the computer) to a Website Database I have. I've used TcpListeners, vars, Amongst other options. Is there a way to let this service work? It runs on C#, and the server runs on Django. The way it works is;

Changed > Log.txt > OnStop send to website

Is there any way I can get it to work like this, or am I doing something wrong? Below is the var method I'm using.

var request = (HttpWebRequest)WebRequest.Create("www.example.com");

var postData = "user=hello";
postData += "&event=world";
postData += "&path=world";
postData += "&stamp=world";
var data = Encoding.ASCII.GetBytes(postData);

request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;

using (var stream = request.GetRequestStream())
{
   stream.Write(data, 0, data.Length);
}

var response = (HttpWebResponse)request.GetResponse();

var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

1 Answers1

0

What do you think about a trigger on the shutdown system? I mean a separate task
Here there is a question

bull90
  • 689
  • 5
  • 12
  • 1
    While this helps with making the service function on shutdown/logoff, it doesn't help with the problem of it not sending the data to the server. Thank you, though! – Jackie Marcano Jul 18 '16 at 16:38