hi,
can anyone give me the code for displaying the files(txt, pdf, word etc.) on to the browser, if the user selects any file.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Raaj KumarPosted Feb 23, 2010, 11:10 PM
Try this snippet,
protected void GetFileNames()
{
DirectoryInfo di = new DirectoryInfo(Server.MapPath("TempFiles"));
FileInfo[] files = di.GetFiles();
string saveLocation = Server.MapPath("TempFiles" + "\\");
foreach (FileInfo item in files)
{
Response.Write("
" + item.Name + "");
}
}
Here TempFiles is the folder inside the server which stores any kind of file. A HREF will link to the file and when you click on the link it will open inside the browser provided the browser should support the file format.
Regards,
raaj
Sam HobbsPosted Feb 23, 2010, 11:04 PM
kiran kumarPosted Feb 23, 2010, 10:47 PM
http://support.microsoft.com/kb/306654
check it out
MARK THE ANSWER IF IT HELPS YOU