如何压缩目录并将其发送到邮件 [英] How to zip a directory and send it to a mail

查看:114
本文介绍了如何压缩目录并将其发送到邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想压缩目录/文件夹并将其发送到邮件地址。

谁能告诉我怎么做?



假设文件夹名称 -

C:/ Pavel



我想要压缩这个完整的文件夹/目录 -

C:/pavel.zip



在zip完整目录之后会发送到一个电子邮件地址。



谢谢

I wanna zip a directory/folder and send it to a mail address.
can anyone tell me how to do this?

Suppose folder name -
C:/Pavel

I wanna compress this full folder/directory to -
C:/pavel.zip

after zip full directory this will be send to a email address.

Thanks

推荐答案

使用ZIP,你可以使用#ziplib:

http://www.icsharpcode.net/opensource/sharpziplib/ [ ^ ]。



另一个选项是使用SevenZipSharp,一个着名的7-Zip的.NET包装器:

http:// en.wikipedia.org/wiki/7-Zip [ ^ ],

http://sevenzipsharp.codeplex.com/ [ ^ ]。



这两个ZIP库都是开源的。



要通过邮件发送结果,您需要使用已注册的媒体类型内容类型) application / zip,请参阅:

http://en.wikipedia.org/wiki / List_of_common_media_types#List_of_common_media_types [ ^ ],

http://www.iana.org/assignments/media-types/application [ ^ ]。



另请参阅下面关于物业的最后一个链接 System.Net.Mail.Attachment.ContentType



请参阅类 System.Net.Mail.MailMessage System.Net.Mail.Attachment 如何用ZIP部分撰写邮件并发送邮件:

http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.net.mail.attachment.aspx [ ^ ],

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



-SA
For working with ZIP, you can use #ziplib:
http://www.icsharpcode.net/opensource/sharpziplib/[^].

Another option is using SevenZipSharp, a .NET wrapper of the famous 7-Zip:
http://en.wikipedia.org/wiki/7-Zip[^],
http://sevenzipsharp.codeplex.com/[^].

Both ZIP libraries are open-source.

For sending the result in a mail, you need to use the registered media type (content type) "application/zip", please see:
http://en.wikipedia.org/wiki/List_of_common_media_types#List_of_common_media_types[^],
http://www.iana.org/assignments/media-types/application[^].

See also the last link below on the property System.Net.Mail.Attachment.ContentType.

Please see the classes System.Net.Mail.MailMessage and System.Net.Mail.Attachment on how to compose a message with the ZIP part and send it:
http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.mail.attachment.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.mail.attachmentbase.contenttype.aspx[^].

—SA


这篇关于如何压缩目录并将其发送到邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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