N
nalla
iam working in a project where i need to provide a link to user such
that he can download a word Document from server (not my local pc).iam
able to do this from my localhost ,but from other pc i need to use
System.Net.WebRequest but i donot know how to use it.
code for access from localhost:
string filename="anjit.doc";
// if (filename != "")
//
// {
//
// string path = Server.MapPath(filename);
// System.Net.WebRequest
//
// System.IO.FileInfo file = new
System.IO.FileInfo(path);
//
// if (file.Exists)
//
// {
//
// Response.Clear();
//
//
Response.AddHeader("Content-Disposition", "attachment;
filename=" + file.Name);
//
//
Response.AddHeader("Content-Length", file.Length.ToString());
//
// Response.ContentType =
"application/octet-stream";
//
//
Response.WriteFile(file.FullName);
//
// Response.End();
//
// }
//
// else
//
// {
//
// Response.Write("This file does
not exist.");
//
// }
i think i have to use below code but it is not working
System.Net.WebRequest myRequest
=System.Net.WebRequest.Create("http://20.198.118.149/anjit/a.txt");
Console.WriteLine(myRequest);
that he can download a word Document from server (not my local pc).iam
able to do this from my localhost ,but from other pc i need to use
System.Net.WebRequest but i donot know how to use it.
code for access from localhost:
string filename="anjit.doc";
// if (filename != "")
//
// {
//
// string path = Server.MapPath(filename);
// System.Net.WebRequest
//
// System.IO.FileInfo file = new
System.IO.FileInfo(path);
//
// if (file.Exists)
//
// {
//
// Response.Clear();
//
//
Response.AddHeader("Content-Disposition", "attachment;
filename=" + file.Name);
//
//
Response.AddHeader("Content-Length", file.Length.ToString());
//
// Response.ContentType =
"application/octet-stream";
//
//
Response.WriteFile(file.FullName);
//
// Response.End();
//
// }
//
// else
//
// {
//
// Response.Write("This file does
not exist.");
//
// }
i think i have to use below code but it is not working
System.Net.WebRequest myRequest
=System.Net.WebRequest.Create("http://20.198.118.149/anjit/a.txt");
Console.WriteLine(myRequest);