By using below code, User can download files from NAS or over the network.
protected void DownloadFile()
{
try
{
string strURL = \\bac\SDF\ASD.XML;
WebClient req = new WebClient();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = true;
response.AddHeader("Content-Disposition", "attachment;filename=\"" + strURL + "\"");
byte[] data = req.DownloadData(strURL);
Response.ContentType = "application/UnknownType";
Response.ContentEncoding = Encoding.Unicode;
response.BinaryWrite(data);
response.End();
}
catch (Exception ex)
{
ex.Data.ToString();
}
}
I am posting this solution for those who might in search for downloading files from Network.
Regards,
AJ83