开发者

how to transfer a files one system to another system

how to transfer a files from a folder of one system to another system in particular folder in c#.net can any he开发者_如何学JAVAlp me on this topic


If you have a UNC with the proper permissions you can just do this:

File.Copy(SourceFile, UncDestinationFile);

You can find out more by reading the documentation here.

If you are not familiar with UNC paths I suggest you read up on it here.

Usually a UNC looks like:

\\Machine\DestinationFolder


File.Move(source, destination)

Should do it provided you have the required permissions and of course both machines are on the same network

Here is the MSDN documentation and an example as well http://msdn.microsoft.com/en-us/library/system.io.file.move.aspx

As an example. Here is some code that will move all files from source to destination: Be sure to replace "\machinename\folder" with your actual names and similarly the destination folder.

  var sourceFolder = "\\machiename\folder";
  var destFolder = @"C:\temp\";
  foreach(var file in Directory.EnumerateFileSystemEntries(sourceFolder))
    File.Move(file, destFolder + Path.GetFileName(file));

Since it's not clear you in your question. File.Move() will "move" the files. That is the files will no longer exist in "destination. File.Copy() will copy files and so you'll have the files in both source and destination after you finish.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜