C#从一台服务器远程复制文件到另一台服务器 [英] C# copy files from one server to another remotely

查看:1067
本文介绍了C#从一台服务器远程复制文件到另一台服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我们在当前项目中使用3台服务器。我们的网络服务器运行在'服务器A'上。

我们的要求是当用户点击一个特定的按钮。一个文件必须从'服务器B'转移到'服务器C'。我们必须得到操作的反馈到'服务器A'

。我们不允许在'Server B'上安装任何东西。如何使用c#实现此功能..请提出任何建议



谢谢,



我尝试了什么:



i在'Server B'中创建了一个共享文件夹并放置那里有一个示例文件。要从'Server B'复制这个文件,我们可以使用cmd命令吗?。



we are using 3 servers in our current project.our webserver is running on say 'Server A'.
our requirement is when user click a particular button.a file must be transferred from 'Server B' to 'Server C'.and we have to get the feedback of the operation to 'server A'
.we are not allowed to install anything on 'Server B'.How can i implement this functionality using c#..please suggest any ideas

Thanks,

What I have tried:

i created a shared folder in 'Server B' and placed a sample file there.to copy this file from 'Server B' can we use cmd commands ?.

推荐答案

你可以使用像File这样的System.IO类来复制文件



File.Copy方法(System.IO) [ ^ ]



在target \destination服务器上创建共享并在它们之间复制文件,因此从\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ txt或者其他什么。您最大的问题是安全性,您的.net代码运行的帐户将需要访问所有这些共享,默认情况下使用的帐户不会。您需要创建具有所需访问权限的帐户,并将IIS配置为使用该帐户而不是默认帐户。



配置匿名身份验证身份(IIS 7) [ ^ ]



或者您可以让它作为应用程序池用户运行并更改应用程序池使用的用户(尝试快速说10次)。
You can use System.IO classes like File to copy files

File.Copy Method (System.IO)[^]

create shares on the target\destination servers and copy the files between them, so from "\\servera\myshare\myfile.txt" to "\\serverb\myshare\myfile.txt" or whatever. Your biggest issue is going to be security, the account your .net code runs under will need access to all of these shares and by default the account used won't. You'll need to create an account with the desired access and configure IIS to use that account rather than the default one.

Configure the Anonymous Authentication Identity (IIS 7)[^]

Or you can leave it running as the app pool user and change the user the app pool uses (try saying that 10 times fast).


这篇关于C#从一台服务器远程复制文件到另一台服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆