andy
andy

Reputation: 543

C# Copy directory to another server

After numerus failed attempts of trying to use robocopy to mirror files accoss to another server as a SQL job(Dont ask).

The job would have to run every 15 minutes and run as a SQL job to copy all transaction logs and backup files and so that is the job fails it reports up in SQL which is then checked by MOM. The job can not just copy the whole directory every time as its about 50gb in size it would just have to mirror the directroy, In other words get rid of the files that dont exist on the source directory and copy the new files that do.

It has been suggested that c# is the best way (and its a good learning curve for me). But my c# knowlege is very minimal.

Sorry I fogot to mention we are on a restricted network and Robocopy was the only option ragerding applications. FTP is alsoo banned.

Help

Thanks

Upvotes: 3

Views: 1160

Answers (6)

Edward Leno
Edward Leno

Reputation: 6327

For a non-programming type option, SyncToy from Microsoft works well to keep file directories in sync. There are different folder options on how to handle changes (updates/deletes). I use this in combination with the Task Scheduler to run at predetermined times during the day. In addition, I also keep a shortcut on my desktop so I can run it 'out of schedule' when necessary.

EDIT:

If the SyncToy UI is not your thing, you can use the underlying framework (Microsoft Sync Framework) http://msdn.microsoft.com/en-us/sync/bb887623.aspx to develop your own UI or just use it in the background.

Upvotes: 0

andy
andy

Reputation: 543

Sorry I fogot to mention we are on a restricted network and Robocopy was the only option ragerding applications. FTP is alsoo banned.

Upvotes: 0

Rup
Rup

Reputation: 34418

As a non-C# option - I'm not sure really why that would help - there's also rsync. I haven't used it on Windows but I've used it on Linux to do this sort of thing. It can run as daemon / client to split the work between the machines. However it only appears to be available on Windows through cygwin, not with the native APIs.

Upvotes: 1

npinti
npinti

Reputation: 52205

If I understand you well, you need to copy a directory over to some server, however, since the directory is 50Gb in size, you need only to move specific files.

If that is the case, then I suggest you take a look at the FileSystemWatcher. It basically "listens" to any changes made to files in a given directory, and you can use those actions to know what action was done (created, edited, deleted) on what file.

Upvotes: 2

Wouter Janssens
Wouter Janssens

Reputation: 1613

You can write a program by yourself or install a tool from Microsoft TyncToy this tool allows you to create folder-pairs that needs to be synchronized. The first time set up the folder-pairs using the GUI but afterwords you can call the tool from command line

Upvotes: 1

Nathan Taylor
Nathan Taylor

Reputation: 24606

It sounds like using FTP to transfer the files would be a good option.

Here's a tutorial on uploading a file with FtpWebRequest using C#: http://www.vcskicks.com/csharp_ftp_upload.php

Upvotes: 0

Related Questions