i want to create a window service that does following
on every 30 sec it checks a folder and if it finds any file in it then it moves all those file to another folder.
how can i do that
can you provide the solution or any link where i can refer to
Loading

Prasant JinagaRank #2,383 · 594 reputationPosted Apr 2, 2013, 1:19 AM EDT
You can use FileSystemwatcher class, else the attached code will work..
Please find the attached code which will keep invoking the directory every 2 sec if there are any files it will move to other directory.
Hope it helps !!!
Thanks,
Prasant
nishant ranjanRank #4,961 · 317 reputationPosted Apr 3, 2013, 1:05 AM EDT
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.IO;
using System.Timers;
namespace movingfile
{
public partial class Service1 : ServiceBase
{
public Timer t1 = null;
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
t1 = new Timer();
this.t1.Enabled = true;
this.t1.Elapsed += new ElapsedEventHandler(t1_Tick);
this.t1.Interval = 10000;
}
protected override void OnStop()
{
this.t1.Enabled = false;
}
public void t1_Tick(object sender, EventArgs e)
{
File.Copy("c:\\input\\*.*", "D:\\copy\\*.*");
File.Move("c:\\input\\*.*", "D:\\output\\*.*");
}
}
}
nishant ranjanRank #4,961 · 317 reputationPosted Apr 4, 2013, 2:43 AM EDT
its moving from one folder to other
but i want it to move within LAN i.e., from one system to other system folder
how can i do this
bhanuprakash inturi51 reputationPosted Aug 27, 2013, 11:35 PM EDT
you told your code is working, can you please share your code, Here I have the same task to do.
Thanks
Bhanu Prakash
pradip Patil30 reputationPosted Jul 9, 2019, 5:16 AM EDT
you told your code is working, can you please share your code, Here I have the same task to do.
Amit GuptaRank #190 · 12.8K reputationPosted Jul 9, 2019, 8:21 AM EDT
Logesh PalaniRank #274 · 9.1K reputationPosted Jan 4, 2020, 1:12 AM EST
Thirumoorthy LakshmananRank #5,421 · 300 reputationPosted Jan 4, 2020, 5:25 AM EST
Laxmidhar SahooRank #383 · 6.6K reputationPosted Jan 4, 2020, 7:28 PM EST
Jignesh KumarRank #91 · 22.9K reputationPosted Jan 5, 2020, 4:25 AM EST
Amit MohantyRank #112 · 20K reputationPosted Jan 5, 2020, 5:38 PM EST
Then you can access it using following syntax
Laxmidhar SahooRank #383 · 6.6K reputationPosted Jan 5, 2020, 6:01 PM EST