如何使用c#asp.net通过FTP发送zip文件夹 [英] how to send zip folder through FTP using c# asp.net

查看:59
本文介绍了如何使用c#asp.net通过FTP发送zip文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个大小为100 MB的压缩文件夹需要通过FTP使用带有c#语法的asp.net在服务器上发送。如果在发送过程中发生中断,是否可以恢复操作?

请回复。

解决方案

没有ZIP文件夹这样的东西。只有一个ZIP文件,因此包装内容无关紧要,文件夹由嵌套文件夹或仅一个文件组成。对于FTP,这只是一个文件,与任何其他文件没有区别。



要充当FTP客户端,只需使用类系统.Net.FtpWebRequest

http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx [ ^ ]。



我从未尝试恢复FTP传输部分传输的文件,但它可能是可能的。我在HTTP下载的HTTP传输中一直这样做。我现在没有机会对它进行测试,所以请自己试一试,告诉我们它是否适合您和您的特定服务器。从文档中,您可以看到您获得FTP操作的请求和响应流,并直接从/向它们读/写。如果您知道已传输文件的大小,则可以检查流 CanSeek

http://msdn.microsoft.com/en-us/library/system.io.stream。 canseek(v = vs.110).aspx [ ^ ]。



如果可以,你可以寻求,跳转到所需的位置是流以跳过已转移的部分: http://msdn.microsoft.com/en-us/library/system.io.stream.seek%28v=vs.110%29.aspx [ ^ ]。



(如果可能的话,因为我刚看到一些专有的图书馆,它们承诺支持部分转移的恢复d文件。我不认为我们应该在这个网站上宣传任何专有软件,但如果感兴趣,你可以轻松找到这样的项目。)



-SA

Hi,

I have zipped folder of size 100 MB need to send it on server through FTP using asp.net with c# grammatically. Is it possible to resume operation if interrupt occur during sending?.
Please reply.

解决方案

There is no such thing as ZIP folder. There is just one ZIP file, so it does not matter what is packed in it, a folder, structured of nested folders or just one file. For FTP, this is just a file, no different from any other file.

To act as an FTP client, just use the class System.Net.FtpWebRequest:
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx[^].

I never tried to resume FTP transfer for a partially transferred file, but it might be possible. I do it all the time for HTTP transfer in my HTTP downloaded. I don't have to opportunity to test it right now, so please try it out by yourself and tell us if it works for you and your particular server or not. From documentation, you can see that you get request and response streams for FTP operations and directly read/write from/to them. If you know the size of already transferred file, you can check if the stream CanSeek:
http://msdn.microsoft.com/en-us/library/system.io.stream.canseek(v=vs.110).aspx[^].

If it can, you can "seek", jump to the desired position is stream to skip already transferred portion: http://msdn.microsoft.com/en-us/library/system.io.stream.seek%28v=vs.110%29.aspx[^].

(If might be possible because I just saw some proprietary libraries which promise to support resume of partially transferred files. I don't think we are supposed to promote any proprietary software on this site, but you can easily find such project if interested.)

—SA


这篇关于如何使用c#asp.net通过FTP发送zip文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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