views:

438

answers:

5

I need to create an Intranet website (page) which allows users to indicate a local network folder to copy to a production location. Currently this is done manually using xcopy in batch files.

What I am looking for is approaches on triggering the copy so it's done in the middle of the night and an approach to copy the files. I suppose I can run xcopy from my application, but is this a good way to do this? Should I use System.IO name space objects to copy the files? Is there a better way all together?

The application will be written in C# and ASP.NET. We currently use .NET 2.0/3.0, but I have no issues using .NET 3.5 if it contains better libraries for the solution.

Basically a user will indicate which network folder they need copied along with some other business information. The folder indicated and all sub-folders need to be copied to target location (not set by user).

If there is already an application out there which does this, I am not opposed to that either. I have no need to write stuff that already exists.

+1  A: 

For the scheduling part you could use Quartz.NET

It won't be difficult to write an xcopy operation in C# using System.IO. In fact, this would give you the greatest degree of flexibility.

kgiannakakis
What about performance compare to xcopy, will it be anywhere close, and is there a way to verify copied files?
Brettski
+2  A: 

For the first problem (copying at midnight), I suggest setting up a scheduled task that runs the already existing batch file (or any program, for that matter)

Mehrdad Afshari
example: c:\Windows\system32\schtasks.exe /Create /st 00:01:00 /tr "c:\myuser\bin\nightwork.cmd" /sc once /tn NameForScheduledTask . If you do a Process.Start() on that string, you will schedule a task to run at 12:01am.
Cheeso
One resistance I am having toward the Windows Scheduled tasks is status feedback to the user. I guess scheduling PowerShell scrips can give more options here?
Brettski
Probably... Scheduler works with arbitrary application. Personally, I have set up a backup strategy on a server that runs a batch file on schedule which runs a simple C# console application with some parameters.
Mehrdad Afshari
+1  A: 

The simplest solution would be to wrap your xcopy commands in a command file and schedule it to run whenever you want as a Scheduled Task on your web server.

If you want to get fancy, you can write up a web interface to the task scheduler - I'm pretty sure I've seen open source examples of that type of application too.

Ron

Ron Savage
A: 

I think you should consider using Windows Powershell to do your copying (or another scripting language if you prefer), driven by Windows Scheduled Tasks. Though you could write an application to do this, I think it would be much more maintainable to have a script that others could edit.

Keltex
A: 

you've tagged this ASP but if you aren't fussy I'd recommend a combination of Windows builtin Scheduled Tasks and rsync. If it really has to be automated from an intranet page (and you're in IE) then some form of ActiveX or downloadable script/application would be needed to configure the schedule.

SpliFF