使用C#,如何将文件从共享网络驱动器复制到本地计算机?请告诉我代码。 [英] Using C#, how do I copy a file from a shared network drive to my local machine? Please hepl me with the code.
本文介绍了使用C#,如何将文件从共享网络驱动器复制到本地计算机?请告诉我代码。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它需要ba控制台应用程序
解决方案
这将是一个简短的程序...
从传统的Hello World程序开始。
http://msdn.microsoft.com/en-us/library/aa288463%28v=vs.71%29.aspx [ ^ ]
以下是复制文件API的一些背景信息。
http://msdn.microsoft.com/en-us/library/system.io.file.copy%28v = vs.110%29.aspx [ ^ ]
将这两者放在一起,你最终会得到类似的东西:
使用系统;
public class HomeWork
{
public static void Main( string [] args)
{
if (args.Length == 2 )
System.IO.File.Copy(args [ 0 ],args [ 1 跨度>]);
else
Console.WriteLine( 预计有两个文件名。);
}
}
编译程序。打开命令窗口并运行它。包括要复制的文件的名称。类似......
HomeWork\\machine\path\to\file。
It needs to b a console application
解决方案
This will be a short program ...
Start with the traditional "Hello World" program.
http://msdn.microsoft.com/en-us/library/aa288463%28v=vs.71%29.aspx[^]
Here's some background on the copy file API.
http://msdn.microsoft.com/en-us/library/system.io.file.copy%28v=vs.110%29.aspx[^]
Put these two together, you'll end up with something like:
using System; public class HomeWork { public static void Main(string[] args) { if (args.Length == 2) System.IO.File.Copy(args[0], args[1]); else Console.WriteLine("Expected two file names."); } }
Compile the program. Open a command window and run it. Include the name of the file you want to copy. Something like ...
HomeWork "\\machine\path\to\file" "."
这篇关于使用C#,如何将文件从共享网络驱动器复制到本地计算机?请告诉我代码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文