Could not find a part of the path 'C:\Inetpub\wwwroot\Vendor\cn.jpg'. [Resolved]

Posted by Hemanth.Gottipati under ASP.NET on 3/1/2013 | Points: 10 | Views : 49768 | Status : [Member] | Replies : 4
Hai


I am developing website using visual studio 2010. Iam trying to save a file in a path. It works fine localhost. i used server.mappath to store the file in the path.


But the same code is not working in IIS. It shows the following error

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Inetpub\wwwroot\Vendor\cn.jpg'.


Could not find a part of the path 'C:\Inetpub\wwwroot\Vendor\cn.jpg'.


Is this is a setup issue. How can i fix this?




Responses

Posted by: Hemanth.Gottipati on: 3/1/2013 [Member] Starter | Points: 25

Up
0
Down

Resolved
Hi thanks for reply...
I am saving image in project folder.local host its working fine..but in iis server Could not find a part of the path 'C:\Inetpub\wwwroot\Vendor\cn.jpg'. these error will be displayed...what is the correct path to get image

Hemanth.Gottipati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santhi on: 3/1/2013 [Member] Starter | Points: 25

Up
0
Down
Hi

Directory not found exception throws when it is not found..
kindly check it whether the image exists.



Thanks & Regards,
Santhi .V

Hemanth.Gottipati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santhi on: 3/1/2013 [Member] Starter | Points: 25

Up
0
Down
Hi

Server.Mappath is enough to locate the image.
Are you saving the images in any folders?
if it is so give the correct path..

Thanks & Regards,
Santhi .V

Hemanth.Gottipati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hemanth.Gottipati on: 3/1/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,
i think server.mappath not working in iis server...
i am using below code now its working fine both local host and iis server..
DirectoryInfo di = new DirectoryInfo(System.Web.Hosting.HostingEnvironment.MapPath("~/Images/PatientPhotos"));
FileInfo[] TXTFiles = di.GetFiles("*.jpg");
if (TXTFiles.Length > 0)
{
bool imageurl = false;

foreach (FileInfo file in TXTFiles)
{

if (file.ToString() != Session["PatientId"] + ".jpg")
{
//string sPhysicalLoc="q:\quotewerks\images\contact systems\contac3s.jpg";
//string virtualFilePath = sPhysicalLoc.Replace(physicalRootDirectoryPath,"~/");

// captureimg.ImageUrl = "../Images/PatientPhotos/no-image.jpg";
captureimg.ImageUrl = "~/Images/PatientPhotos/no-image.jpg";

}
else
{
imageurl = true;
break;

}
}
if (imageurl == true)
{
// captureimg.ImageUrl = VirtualPathUtility.ToAbsolute("~/Images/PatientPhotos/" + Session["PatientId"].ToString() + ".jpg");
captureimg.ImageUrl = "~/Images/PatientPhotos/" + Session["PatientId"].ToString() + ".jpg";
}

}

Hemanth.Gottipati, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response