如何压缩目录并将其发送到邮件(附加为zip文件)

编程入门 行业动态 更新时间:2024-10-28 10:27:41
本文介绍了如何压缩目录并将其发送到邮件(附加为zip文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想压缩目录/文件夹并将其发送到邮件地址。 谁能告诉我怎么做? 假设文件夹名称 - 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

推荐答案

使用.NET 4.5,添加对System.IO.Compression的引用。 FileSystem并执行以下操作: Using .NET 4.5, add a reference to System.IO.Compression.FileSystem and do the following: static void Main(string[] args) { string startPath = @"c:\Pavel"; string zipPath = @"C:\Pavel.zip"; ZipFile.CreateFromDirectory(startPath, zipPath); }

然后按照本文的说明将文件附加到电子邮件: msdn.microsoft/en-us/library/ system.mail.mailmessage.attachments.aspx [ ^ ]

更多推荐

如何压缩目录并将其发送到邮件(附加为zip文件)

本文发布于:2023-07-13 22:20:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1102475.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送到   加为   邮件   文件   目录

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!