如何通过TCP在C#中发送文件夹?

发布于 2024-11-03 01:16:58 字数 241 浏览 3 评论 0原文

我在寻找通过 TCP 发送整个文件夹的方法时遇到困难。我最初的想法是发送者发送一个包含给定文件路径的字符串,例如 C://MyFolder/MySubFolder/MyFile,然后接收者创建文件夹和子文件夹。然后,发送者继续发送包含其目录的文件。

我认为不言而喻,这不是最好的方法。有更好的方法吗?

编辑:

抱歉,如果我有点含糊的话。我有一个文件传输应用程序,显然可以发送/接收文件,我想添加一种发送整个文件夹的方法。

I'm having trouble looking for a way to send whole folders over TCP. My initial idea was that the sender sends a string that contains the path of a given file like C://MyFolder/MySubFolder/MyFile then the receiver creates the folders and subfolders. The sender then goes ahead with the sending of the files containing their directory.

I think it goes without saying that this is not the best method in doing this. Is there a better approach?

EDIT:

Sorry if I was a little vague. I have a file transfer app that sends sends/receives files obviously and I want to add a way to send whole folders.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

但可醉心 2024-11-10 01:16:58

为此,您需要某种文件传输协议(即 FTP)。使用易于设置的 C# FTP 服务器库(即:http://sourceforge.net/projects/csftpserver/ )在发送端使用FtpWebRequest在客户端获取整个文件夹结构。

You need some sort of a file transfer protocol for that (i.e. FTP). Use an easy to setup c# FTP server library (i.e. this one: http://sourceforge.net/projects/csftpserver/) on the sending side and use FtpWebRequest on the client side to get the whole folder structure.

落花浅忆 2024-11-10 01:16:58

使用著名的归档方法(zip、rar...)并传输数据。在对等端提取。这样你就可以节省:

  1. 实施一个容易出错的
    递归模式。
  2. 您的带宽

Use famous archiving methods (zip, rar...) and transfer data. The extract the at the peer side. This way you save:

  1. Implementing an error-prone
    recursive pattern.
  2. Your bandwidth
合久必婚 2024-11-10 01:16:58

您是否为此目的查看了现有协议?看来你想克隆 FTP,也许使用像 tar 位于两者之间。

Have you looked at existing protocols for this purpose? It seems you want to clone FTP, maybe with a streaming mechanism like tar in between.

赠佳期 2024-11-10 01:16:58

如果您考虑压缩/压缩:
您可以查看 GZipStream 类。

http://www.geekpedia.com/tutorial190_Zipping-files-using-GZipStream.html

If you consider zipping/compressing:
You could have a look at GZipStream class for that.

http://www.geekpedia.com/tutorial190_Zipping-files-using-GZipStream.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文