using Microsoft.SharePoint;
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 HelloworldService
{
public partial class Service1 : ServiceBase
{
System.Timers.Timer timer = new System.Timers.Timer();
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\abhas.txt", true);
file.WriteLine(DateTime.Now + "Service Has Started");
timer.Interval = 60000; // 60 seconds
timer.Enabled = true;
timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer);
timer.Start();
String fileName = string.Empty; String filePath;
filePath = System.Configuration.ConfigurationManager.AppSettings["Folderpath"].ToString();
string[] filePaths = Directory.GetFiles(filePath);
DirectoryInfo di = new DirectoryInfo("C:\\Dropbox");
FileInfo[] fi = di.GetFiles("*", SearchOption.AllDirectories);
if (Convert.ToInt32(fi.Length)>0)
{
file.WriteLine(DateTime.Now + "There ares ome files");
}
else
{
file.WriteLine(DateTime.Now + "No Files Present");
}
file.Close();
}
private void OnTimer(object sender, System.Timers.ElapsedEventArgs e)
{
System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\abhas.txt", true);
String fileName = string.Empty; String filePath;
filePath = System.Configuration.ConfigurationManager.AppSettings["Folderpath"].ToString();
string[] filePaths = Directory.GetFiles(filePath);
DirectoryInfo di = new DirectoryInfo("C:\\Dropbox");
FileInfo[] fi = di.GetFiles("*", SearchOption.AllDirectories);
if (Convert.ToInt32(fi.Length) > 0)
{
file.WriteLine(DateTime.Now + "There ares Some files");
}
else
{
file.WriteLine(DateTime.Now + "No Files Present");
}
file.Close();
}
protected override void OnStop()
{
}
}
}
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 HelloworldService
{
public partial class Service1 : ServiceBase
{
System.Timers.Timer timer = new System.Timers.Timer();
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\abhas.txt", true);
file.WriteLine(DateTime.Now + "Service Has Started");
timer.Interval = 60000; // 60 seconds
timer.Enabled = true;
timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer);
timer.Start();
String fileName = string.Empty; String filePath;
filePath = System.Configuration.ConfigurationManager.AppSettings["Folderpath"].ToString();
string[] filePaths = Directory.GetFiles(filePath);
DirectoryInfo di = new DirectoryInfo("C:\\Dropbox");
FileInfo[] fi = di.GetFiles("*", SearchOption.AllDirectories);
if (Convert.ToInt32(fi.Length)>0)
{
file.WriteLine(DateTime.Now + "There ares ome files");
}
else
{
file.WriteLine(DateTime.Now + "No Files Present");
}
file.Close();
}
private void OnTimer(object sender, System.Timers.ElapsedEventArgs e)
{
System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\abhas.txt", true);
String fileName = string.Empty; String filePath;
filePath = System.Configuration.ConfigurationManager.AppSettings["Folderpath"].ToString();
string[] filePaths = Directory.GetFiles(filePath);
DirectoryInfo di = new DirectoryInfo("C:\\Dropbox");
FileInfo[] fi = di.GetFiles("*", SearchOption.AllDirectories);
if (Convert.ToInt32(fi.Length) > 0)
{
file.WriteLine(DateTime.Now + "There ares Some files");
}
else
{
file.WriteLine(DateTime.Now + "No Files Present");
}
file.Close();
}
protected override void OnStop()
{
}
}
}