Wednesday, October 24, 2007

Send Files to IP address in C#


 Send Files to IP address in C#
=============================

string sourceDir = @"C:\\tt";
string destIP = @"\\10.10.10.10\shared-folder-amit";
string[] sourceFiles = Directory.GetFiles(sourceDir, "*", SearchOption.AllDirectories);
foreach (string files in sourceFiles) {
  string localFile = files.Replace(sourceDir, "");
  if (!Directory.Exists(Path.GetDirectoryName(destIP + "\\" + localFile)))
    Directory.CreateDirectory(Path.GetDirectoryName(destIP + "\\" + localFile));
  File.Copy(files, destIP + "\\" + localFile, true);
}

No comments:

Post a Comment