.net - Server.MapPath returning a path with a folder that doesn’t exists -


i have following code:

var dir = @"content\posts\" + yr + @"\" + mnth + @"\"; var = path.combine(dir, dy.tostring() + pid.tostring() + ".txt"); //a contains: "content\\posts\\2013\\8\\file01.txt" stts = obj.notifymail(title, writeup, "author@gmail.com", a); 

and in notifymail function have this:

public bool notifymail(string subject, string body, string toadd, string filepath)     {         … string attachments = httpcontext.current.server.mappath(filepath); //now here attachments contains: "g:\\program files\\derby\\work\\development\\proj\\proj\\`post`\\content\\posts\\2013\\8\\file01.txt"              var attchmnts = new linkedresource(attachments);             attchmnts.contentid = "attchmnts"; …     } 

now problem in notifymail when attachments retrieving physical file path through server.mappath returning path invalid folder included in i.e. post folder doesn't exists anywhere, not in hard drive , have no idea how been picked , returned. said due problem linkedresource(attachments); throwing exception:

{"could not find part of path ‘g:\\program files\\derby\\work\\development\\proj\\proj\\post\\content\\posts\\2013\\8\\file01.txt"’ 

i don't believe mappath guarantees path exists, tacks virtual path context path.

i think problem you're using

 httpcontext.current.server.mappath 

try using

httpcontext.current.request.mappath 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -