Saya mengalami masalah ketika saya mencoba menghapus file saya tetapi saya mendapatkan pengecualian.
if (result == "Success")
{
if (FileUpload.HasFile)
{
try
{
File.Delete(Request.PhysicalApplicationPath + app_settings.login_images + txtUploadStatus.Text);
string filename = Path.GetFileName(btnFileUpload.FileName);
btnFileUpload.SaveAs(Request.PhysicalApplicationPath + app_settings.login_images + filename);
}
catch (Exception ex)
{
Message(ex.ToString());
}
}
}
Saya juga harus mencatat bahwa folder yang saya coba hapus memiliki kontrol penuh terhadap layanan jaringan.
Pesan pengecualian penuh adalah:
System.UnauthorizedAccessException: Akses ke jalur 'C: \ Users \ gowdyn \ Documents \ Visual Studio 2008 \ Projects \ hybrid \ hybrid \ temp_loginimages \ enviromental.jpg' ditolak. di System.IO .__ Error.WinIOError (Int32 errorCode, String maybeFullPath) di System.IO.File.Delete (String path) di hybrid.User_Controls.Imgloader_Add_Edit_Tbl.btnUpdate_Click (pengirim objek, EventArg e) di C: \ Users \ gow Documents \ Visual Studio 2008 \ Projects \ hybrid \ hybrid \ User_Controls \ Imgloader_Add_Edit_Tbl.ascx.cs: baris 242
Ada ide?