Opening Word Document in Browser Error: could not find a path in ASP.Net

Last Reply one year ago By dharmendr

Posted one year ago

Dear All,

i'm following the below link 

Display binary Word document from Database in browser using C# and VB.Net in ASP.Net

But i'm getting the error at this line 

File.WriteAllBytes(Server.MapPath("~/Temp/" + fileextension), bytes);

Error message: could not find a path c:\....

Any comments for above

Thanks in advance

Posted one year ago

Make sure Temp folder is exist in the projects root folder.

Posted one year ago

Yes you need to create the Temp folder.

Else you need to add the below code for Create folder if not present.


//If Directory not present, create it.
if (!Directory.Exists(Server.MapPath("~/Temp/")))


'If Directory not present, create it.
If Not Directory.Exists(Server.MapPath("~/Temp/")) Then
End If