本文介绍了如何压缩目录并将其发送到邮件(附加为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文件)
发布评论