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();
這是我的代碼..和我在服務器上運行讓我這個錯誤的FileIOPermission在網頁
System.Security.SecurityException:請求類型 「System.Security.Permissions的許可。 FileIOPermission的,mscorlib程序, 版本= 2.0.0.0,文化=中性公鑰= b77a5c561934e089' 失敗....
請解決該E rror ......
簡單:你不必訪問這些文件和/或目錄的一個許可。 **我們無法解決這個問題 - 你必須自己解決!通過你的代碼進行調試 - **完全**發生這種錯誤,什麼行? –
我也會重構代碼,有很多重複的代碼 – Giedrius