我有一个问题,我试图删除我的文件,但我得到一个异常。
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());
}
}
}
我还应该注意,我试图删除的文件夹拥有对网络服务的完全控制权。
完整的异常消息是:
系统。unauthoredaccessexception:拒绝访问路径“C:\Users\gowdyn\Documents\Visual Studio 2008\Projects\hybrid\hybrid\temp_loginimages\ environment .jpg”在System.IO.__Error。WinIOError(Int32 errorCode, String maybeFullPath)在System.IO.File。删除hybrid.User_Controls.Imgloader_Add_Edit_Tbl的字符串路径。C:\Users\gowdyn\Documents\Visual Studio 2008\Projects\hybrid\hybrid\User_Controls\ imgloader_add_edit_tbl.ascxx .cs:第242行:btnUpdate_Click(对象sender, EventArgs e
什么好主意吗?