如何在 C# 中附加文件时显示进度条
我正在通过 C# 附加邮件文件。我正在使用下面的代码:
Attachment data = new Attachment(fileName);
mailMsg.Attachments.Add(data);
我想在附加文件时显示进度条。我该怎么做?
I am attaching file for mail through C#. I am using below code:
Attachment data = new Attachment(fileName);
mailMsg.Attachments.Add(data);
I want to show a progress bar while attaching file. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非
mailMsg
对象具有某种进度事件,否则您可能无法获取单个附件的进度。但是,如果您要附加多个文件,则可以以百分比形式报告已完成的文件与总文件的比率。为此,请向窗口添加一个
ProgressBar
,然后在每个文件完成后更新它的值。Unless the
mailMsg
object has some kind of progress event, you probably can't get the progress for a single attatchment.However, if you are attatching multiple files, you can report the ratio of files completed to total files as a percentage instead. To do that, add a
ProgressBar
to your window, then update the value of it after each file is done.