asp.net - why my server.mappath() is not working in another pc? -


i have project in pc..but when saving uploaded files in folder inside project.now when transferring project in pc server.mappath() not working..why??

my problem upload function

protected void addproblem_click(object sender, eventargs e) {     string filepath;     if (problemupload.hasfile)         try         {             if(problemupload.postedfile.contenttype=="application/pdf")             {                // problemupload.saveas("f:\\0\\my project website\\sgipc\\problems\\" + problemupload.filename);                // filepath = "f:\\0\\my project website\\sgipc\\problems\\" + problemupload.postedfile.filename;                 problemupload.saveas(server.mappath("\\sgipc\\problems\\" + problemupload.filename));                 filepath = server.mappath(problemupload.postedfile.filename);                 string con = " ";                 con = configurationmanager.connectionstrings["connectionstring"].tostring();                 sqlconnection objsqlconn = new sqlconnection(con);                 objsqlconn.open();                 string userid = convert.tostring(session["userid"]);                 sqlcommand cmd = new sqlcommand("insert problemtable(problemname,problempath,userid,status) values('" + probbox.text + "','" + filepath + "','" + userid + "','" + "pending" + "')", objsqlconn);                 cmd.executenonquery();                 objsqlconn.close();             }             else             {                 response.write("<script>alert('" + "only pdf format allowed..." + "')</script>");             }          }         catch (exception ex)         {             response.write("<script>alert('" + ex.tostring() + "')</script>");         }     else     {         response.write("<script>alert('" + "you have not specified file..." + "')</script>");     }   } 

i getting error

"system.invalidoperationexception: failed map path '/sgipc/tutorials/v6-1446-1449.pdf'."

while uploading file pc..but pc works fine..

i think there problem in server.mappath try syntax fileuploadcontrol.saveas(server.mappath("~/sgipc/problems/" + problemupload.filename));

~ sign automatic configure path server , better \\ sign map path..


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -