Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace WindowsService1
{
public partial class VulnService : ServiceBase
{
public VulnService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
LogService("Service is Started");
}
protected override void OnStop()
{
LogService("Service Stoped");
}
private void LogService(string content)
{
FileStream fs = new FileStream(@"c:\VulnServiceLog.txt", FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine(content);
sw.Flush();
sw.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment