如何删除文件夹中的垂直文件

问题描述:

亲爱的朋友,

在这里,我开发了一个Web应用程序,并iam将Pdf文件保存并将其存储在一个文件夹中.iam删除了垂直记录.iam存储在文件夹路径中的文件也应该旨在获得一些Exception错误.

代码:

Dear Friends,

Here i have Developed one web application and iam saving Pdf files and iam storing that file in one folder.While iam deleting the perticular record.That file which iam storing in folder path it should also but aim getting some Exception error.

The Code:

else if (e.CommandName == "Delete")
     {
         string filename;
         int index = Convert.ToInt32(e.CommandArgument);
         objinfo.IntInformationID = index;
         DataSet ds = objinfo.DeletePdfDocument();
         string strPath = string.Empty;
         filename = ds.Tables[0].Rows[0]["strDocument"].ToString();
         strPath = Server.MapPath("Documents") + "\\" + filename;
         File.Delete(strPath);

         objinfo.GetinfoDelete();
         Response.Redirect("frmManageCode.aspx");
     }





错误是:拒绝访问路径``D:\ AnilKumarBackUp \ Development Center \ USAID_EMISICT \ ICT_Forms \ Documents \ DPO12334.pdf''.


如果有任何有关此方面的信息,请与我分享.


问候,

AnilKumar.D





Error is: Access to the path ''D:\AnilKumarBackUp\Developement Center\USAID_EMISICT\ICT_Forms\Documents\DPO12334.pdf'' is denied.


if any information regarding this please share with me.


Regards,

AnilKumar.D

由您的pdf 文件组成的folder 是否具有要删除的permission ?
请检查并grant permission 到文件夹.
另一种可能性是您的文件已被使用.


如果有解决方案,请回答.

谢谢
AShish
Do the folder which consists of your pdf file have permission for delete??
please check and grant permission to the folder.
another possibility is that your file is already in use.


make it answer if you got your solution.

Thanks
AShish


这可能是因为当您请求网页时,您的网络服务器负责提供服务,此处的用户是您的网络服务器,并且它可能无权从该文件夹中删除文件.
尝试将保存文件的文件夹更改为Web根文件夹的某个子目录中的某个文件夹,或者将Web服务器的读写权限授予该特定文件夹.
This can be because when you request a web page, your webserver is responsible for serving and here the user is your web server and it may not have permission to delete a file from this folder.
Try to change the folder where you save the file to some folder in some subdirectory of your web root folder or give read write permission for your webserver to that particular folder.