如何在 C# 中附加文件时显示进度条

发布于 2024-10-06 15:59:30 字数 168 浏览 0 评论 0原文

我正在通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜光 2024-10-13 15:59:30

除非 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文