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

Last Reply 11 months ago By dharmendr

Posted 11 months 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 11 months 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