【发布时间】:2014-05-08 22:19:16
【问题描述】:
所以我的程序可以打开保存在数据库中的附件。打开微软文档时出现问题。如果该过程是唯一的,那么它将打开。如果它是重复的,它将崩溃。我尝试了 try/catch,但我正在使用协程来显示错误消息,并且 try/catch 不允许 Yield 返回。
我尝试过的:
public IEnumerable<IResult> OpenAttachment()
{
FolderBrowserDialog sfg = new FolderBrowserDialog();
string path = sfg.SelectedPath;
byte[] bytes = AttachmentSelectedItem.FileArray;
string Name = AttachmentSelectedItem.FileName;
try
{
System.IO.File.WriteAllBytes(Path.GetTempPath() + "\\" + Name, bytes);
Process.Start(Path.GetTempPath() + "\\" + Name);
yield return ErrorView.Show("File Is Uploaded");
}
catch
{
yield return ErrorView.Show("Please close Existing File");
}
}
我想知道我可以使用另一种方法来使用我的协程吗?
【问题讨论】:
标签: c#