SirReadAlot
asked on
Invalid path for MapPath
Hi experts,
My application is trying to get to this path but it comes up with this error,
Does anyone know a work round?
thanks
Invalid path for MapPath 'C:\Inetpub\wwwroot\AutoDa taCaputure _2\Files\' . A virtual path is expected.
My application is trying to get to this path but it comes up with this error,
Does anyone know a work round?
thanks
Invalid path for MapPath 'C:\Inetpub\wwwroot\AutoDa
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Change this:
postedFile.SaveAs(HttpCont ext.Curren t.Server.M apPath("C: \\Inetpub\ \wwwroot\\ AutoDataCa puture_2\\ Files\\")+ Path.GetFileName(postedFil e.FileName ));
to the web path where you want the file saved. For example, assuming that wwwroot is the main root of the website and the others are directories then use:
postedFile.SaveAs(HttpCont ext.Curren t.Server.M apPath("/A utoDataCap uture_2/Fi les/")+ Path.GetFileName(postedFil e.FileName ));
postedFile.SaveAs(HttpCont
to the web path where you want the file saved. For example, assuming that wwwroot is the main root of the website and the others are directories then use:
postedFile.SaveAs(HttpCont
ASKER
will try this
ASKER
hi it now says that it can't find the path to the file which I an browsing to!!
the file is there so the path to it is right
Could not find a part of the path "c:\inetpub\wwwroot\AutoDa taCaputure _2\Files\N ykbulkship .xls".
the file is there so the path to it is right
Could not find a part of the path "c:\inetpub\wwwroot\AutoDa
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
postedFile.SaveAs(HttpCont ext.Curren t.Server.M apPath("/A utoDataCap uture_2/Fi les/")+ Path.GetFileName(postedFil e.FileName ));
//postedFile.SaveAs(HttpCo ntext.Curr ent.Server .MapPath(" \\AutoData Caputure_2 \\Files\\" )+ Path.GetFileName(postedFil e.FileName ));
if (postedFile.ContentType == "application/vnd.ms-excel" )
{
conn = new OleDbConnection("Provider= Microsoft. Jet.OLEDB. 4.0;Data Source=" + HttpContext.Current.Server .MapPath(" /AutoDataC aputure_2/ Files/") + Path.GetFileName(postedFil e.FileName ) +";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"");
//postedFile.SaveAs(HttpCo
if (postedFile.ContentType == "application/vnd.ms-excel"
{
conn = new OleDbConnection("Provider=
ASKER
I think you are looking for the method “GetAppPath” in HttpWorkerRequest class
ok will try anything
ok will try anything
ASKER
{
//if (postedFile != null && postedFile.FileName.Length
if(!checkEmployer())
{
lblErrorReport.Text = "Employer ID already exists in the Database.";
}
else
{
this.lblErrorReport.Text = "";
this.lblfilename.Text = Path.GetFileName(postedFil
// postedFile.SaveAs("C:\\cod
postedFile.SaveAs(HttpCont
thanks