Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

Make Services Which Will Check File in Folder and Run Batch File

$
0
0

I want to make the services that I would like to install in server, it should run the batch file once I will send one specific file to the folder

I start from this can someone guide me how i finish.
Thanks

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.ServiceProcess;
using System.Text;
using System.Threading;

namespace FolderWatch
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }

        private System.Timers.Timer timer1;
        protected override void OnStart(string[] args)
        {
            WriteLogs("Starting .....  ");
            timer1 = new System.Timers.Timer();
            timer1.Interval = 15000;
            timer1.Elapsed += timer1_Elapsed;
            timer1.Start();
        }

        void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            //WriteLogs("Interval click");
            timer1.Stop();
            watching();
            timer1.Start();
        }

        private static void watching()
        {
            try
            {
               // WriteLogs("Watching Start");
                string sourcePath = @"C:\ESLFile\";


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>