Hi Friends,
Why i am getting the below error when i try to delete the image from folder through .net application
System.UnauthorizedAccessException: Access to the path 'Z:\WebApps\DotnetConversion\ITSNET\its_pic1\643825_2.jpg' is denied.
i tried with giving full access to folded.
i tried with giving full access to ASPNET under security tab in properties of the folder
i tried with giving full access to Network Service under security tab in properties of the folder
please help me on this.
Access to the path is denied
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sunny SharmaRank #223 · 11.1K reputationPosted Oct 23, 2013, 10:22 PM EDT
please share your code.
Rajesh S108 reputationPosted Oct 23, 2013, 11:06 PM EDT
FileInfo File_obj = null;
String strpathexists = String.Empty;
strpathexists="Z:\WebApps\DotnetConversion\ITSNET\its_pic1\643825_2.jpg";
File_obj = null;
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Oct 23, 2013, 11:43 PM EDT
use
Server.MapPath();.
example:
string path = Server.MapPath("its_pic1//643825_2.jpg");// check the path in project
FileInfo file = new FileInfo(path);
if (file.Exists)//check file exsit or not
{
file.Delete();
}