【发布时间】:2010-05-20 17:23:42
【问题描述】:
将文件上传到 Rackspace Cloud Files 时出现以下异常:
安全异常
说明:应用程序试图执行未执行的操作 安全策略允许的。到 授予此应用程序所需的权限 权限请联系您的系统 管理员或更改 应用程序的信任级别 配置文件。异常详情:System.Security.SecurityException: 请求类型的许可 'System.Security.Permissions.FileIOPermission, mscorlib,版本=2.0.0.0, 文化=中立, PublicKeyToken=b77a5c561934e089' 失败
这似乎只发生在这个文件上。
这种情况发生在我检查唯一文件名的方法中,但我似乎无法弄清楚原因。
private string GetUniqueStorageItemName(string storageItemName)
{
int count = 0;
string Name = "";
if (cloudConnection.GetContainerItemList(Container).Contains(storageItemName))
{
System.IO.FileInfo f = new System.IO.FileInfo(storageItemName); // error on this line
if (!string.IsNullOrEmpty(f.Extension))
{
Name = f.Name.Substring(0, f.Name.LastIndexOf('.'));
}
else
{
Name = f.Name;
}
while (cloudConnection.GetContainerItemList(Container).Contains(storageItemName))
{
count++;
storageItemName = Name + count.ToString() + f.Extension;
}
}
return storageItemName;
}
【问题讨论】:
-
好的,有时只是发布问题有助于阐明问题。该文件已经存在于服务器上......我想这里的问题是“为什么我不能使用 FileInfo”或者“我真的需要使用它吗 - 我想我可以绕过它”
标签: c# asp.net rackspace cloudfiles