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, Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089' 失败....
请解决此错误......
答案 0 :(得分:1)
检查IIS应用程序池的Windows标识。
检查应用程序正在访问的文件夹和文件的安全设置。
检查Web应用程序是否正在使用模拟。
根据需要调整权利。
答案 1 :(得分:1)
检查您的托管面板并更改上传图片文件夹中IIS用户的权限。
快乐编码:)