0
if (!Directory.Exists(Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//OriginalImages"))
{
    Directory.CreateDirectory(Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//OriginalImages");
}
if (File.Exists(Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//" + fuImageName.FileName.ToString()))
{
    File.Delete(Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//" + fuImageName.FileName.ToString());
}
if (File.Exists(Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//OriginalImages//" + fuImageName.FileName.ToString()))
{
    File.Delete(Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//OriginalImages//" + fuImageName.FileName.ToString());
}
fuImageName.SaveAs(Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//" + fuImageName.FileName.ToString());

if (!Directory.Exists(Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//ThumbNailImages"))
{
    Directory.CreateDirectory(Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//ThumbNailImages");
}

string Path = Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//" + fuImageName.FileName.ToString();
Bitmap bmp1 = CreateThumbnail(Path, 400, 500);

string OutputFilename1 = fuImageName.FileName.ToString();
bmp1.Save(Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//OriginalImages//" + OutputFilename1.ToString(), System.Drawing.Imaging.ImageFormat.Jpeg);

bmp1.Dispose();

Bitmap bmp = CreateThumbnail(Path, 100, 100);

string OutputFilename = "Thumb_" + fuImageName.FileName.ToString();
bmp.Save(Request.PhysicalApplicationPath + "Images//Products//" + ddlCategory.SelectedValue.ToString().Trim() + "//" + ProductMasterId.ToString().Trim() + "//ThumbNailImages//" + OutputFilename.ToString(), System.Drawing.Imaging.ImageFormat.Jpeg);

bmp.Dispose();

ClearAll();

这是我的代码..我在服务器上运行得到这个错误

System.Security.SecurityException:请求“System.Security.Permissions.FileIOPermission,mscorlib,版本=2.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”类型的权限失败......

请解决这个错误......

4

2 回答 2

1

检查 IIS 应用程序池的 Windows 标识。

检查应用程序正在访问的文件夹和文件的安全设置。

检查 Web 应用程序是否使用模拟。

根据需要调整权限。

于 2012-08-29T05:48:19.113 回答
1

检查您的托管面板并更改 IIS 用户对上传图像文件夹的权限。

快乐编码:)

于 2015-06-27T09:13:32.940 回答