从远程计算机收集文件 [英] Collecting File from remote computer

查看:80
本文介绍了从远程计算机收集文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.


我正在使用基于客户端服务器的Windows应用程序.我有两个控制台,一个是客户端,另一个是服务器.我想将文件从客户端PC收集到服务器PC.

我该怎么做?

我尝试了

Hi .


I am working client server based windows application. I have two console, one is client and other is server . I want to collect the file from client pc to server Pc.

How i do this?

I have tried

File.Copy() 

方法,没有共享文件夹不起作用.

请帮助我.

提前致谢.

method,without share folder its not working.

Please help me in this.

Thanks in Advance.

推荐答案

如果要使用File.Copy,则需要为此提供网络凭据.
http://stackoverflow.com/questions/766033/copy-文件到远程计算机使用远程管理凭据 [ http://stackoverflow. com/questions/295538/如何在连接到网络共享时提供用户名和密码 [ ^ ]

在客户端服务器应用程序中,客户端可以读取文件并将数据发送到服务器应用程序,服务器可以将其保存在任何需要的地方.
If you want to use File.Copy, you need to provide network credentials for that.
http://stackoverflow.com/questions/766033/copy-file-to-remote-computer-using-remote-admin-credentials[^]
http://stackoverflow.com/questions/295538/how-to-provide-user-name-and-password-when-connecting-to-a-network-share[^]

In client-server application, client can read the file and send data to server application, and server would save it wherever it wants.


如果不能自己奇迹般地工作.您需要提供具有文件复制操作的服务合同(对于WCF)或具有文件复制功能的服务接口.一种众所周知的协议是FTP(也包括SFTP,FTPS).除了服务之外,您还可以在服务部分上简单地配置并运行一些FTP服务.

无论如何,您始终可以通过服务接口或服务合同使用自己的应用程序级协议.

顺便说一句,我怀疑您创建了一个真正的服务.什么控制台?真正的东西是Windows服务.它不能使用控制台,因为它可以在用户登录和注销时或在任何人登录之前保持工作状态.



如果您不熟悉WCF,则需要从头开始:
http://msdn.microsoft.com/en-us/library/ms731082.aspx [ ^ ].

此演练可能非常有帮助:
http://msdn.microsoft.com/en-us/library/ms731082.aspx [ ^ ].

您可以使用不同级别的网络,而不仅仅是WCF.
请查看我在以前的回答中所做的概述:
如何将byte []发送到另一台PC [ ^ ],
在局域网上与两个Windows应用程序进行通信. [ ^ ].

—SA
If cannot miraculously work by itself. You need to provide a service contract which has a file copy operation (in case of WCF), or service interface which has a function of file copy. One well-known protocol is FTP (also SFTP, FTPS). You can simply install configure and run some FTP service on your service part, in addition to your service.

Anyway, you can always use your own application-level protocol using service interface or service contract.

By the way, I doubt you created a real service. What console? The real thing is the Windows Service; it cannot use console as it keeps working if the user log in and out or before anyone logged in.



If you''re not familiar with WCF, you will need to start with very beginning:
http://msdn.microsoft.com/en-us/library/ms731082.aspx[^].

This walk-through can be very helpful:
http://msdn.microsoft.com/en-us/library/ms731082.aspx[^].

You can use different levels of networking, not just WCF.
Please see my overview I''ve done in my previous answers:
how i can send byte[] to other pc[^],
Communication b/w two Windows applications on LAN.[^].

—SA


这篇关于从远程计算机收集文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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