如何在 C# (windows app) 中将文件从本地系统复制到其他系统?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/944619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 03:55:48  来源:igfitidea点击:

How to copy file from local system to other system in C# (windows app)?

c#file-copying

提问by Dhana

I need to load help files from my windows C# application and move/copy to other system (to its local drive). Application (same C# windows application) on the local system will use it for help.

我需要从我的 Windows C# 应用程序加载帮助文件并移动/复制到其他系统(到其本地驱动器)。本地系统上的应用程序(相同的 C# windows 应用程序)将使用它来获取帮助。

What needs to be done to accomplish this?

需要做什么来实现这一目标?

I understand File.Copy()but i don't know, will it hold for remote system also?

我明白File.Copy()但我不知道,它也适用于远程系统吗?

采纳答案by jerryjvl

File.Copy(
    @"C:\localpath\file.hlp", 
    @"\remotemachinename\localpathonremotemachine\file.hlp");

Or something along those lines... the second value is a UNC path.

或者类似的东西……第二个值是一个 UNC 路径。

And in case the target location needs a login and password, the following answer is applicable: Copy file to remote computer using remote admin credentials(Thanks to Carlos Rendon for finding it).

如果目标位置需要登录名和密码,以下答案适用:使用远程管理员凭据将文件复制到远程计算机(感谢 Carlos Rendon 找到它)。

回答by gimel

File.Copy()Copies an existing file to a new file. The target can be a remote share (UNC).

File.Copy()将现有文件复制到新文件。目标可以是远程共享 (UNC)。