Lar*_*sky 2 .net c# outlook vsto outlook-addin
我在为Outlook编写的VSTO加载项中有以下代码:
savefolder = Regex.Replace(Guid.NewGuid().ToString(), @"[- ]", String.Empty);
savepathfull = string.Format(@"{0}{1}", netloc, savefolder);
DirectoryInfo di = new DirectoryInfo(@savepathfull);
if (!(di.Exists))
Directory.CreateDirectory(@savepathfull);
removedFiles = new List<string>();
for (int d = attachs.Count; d > 0; d--)
{
if (attachs[d].Size > smallAttachment)
{
removedFiles.Add(attachs[d].FileName);
attachs[d].SaveAsFile(savepathfull);
}
}
Run Code Online (Sandbox Code Playgroud)
一切正常,直到我尝试保存附件,此时我收到UnauthorizedAccessException.我知道我的测试用户拥有该文件夹的完全权限,但我仍然收到此错误.
想法?
谢谢.
调用时需要提供有效的文件名Attachment.SaveAsFile.您正在尝试保存到目录,而不是文件.有关参考代码,请参阅MSDN .
attachs[d].SaveAsFile(Path.Combine(savepathfull, attachs[d].DisplayName);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
766 次 |
| 最近记录: |