Rohit Rohit - 1 year ago 140
ASP.NET (C#) Question

Download file from a shared folder on network

I am working on an application. I am showing user the list of files from a shared folder on network and I want user to be able to download any file from the list. But I am not able to locate that file in the code I get

Invalid URI: The format of the URI could not be determined.

Code block -

var uri = new Uri(filePath); // Here I get the error
var fName = Path.GetFullPath(uri.LocalPath);
var fileInfo = new FileInfo(fName);

var response = HttpContext.Current.Response;


response.Buffer = true;

response.AddHeader("Content-Description", "attachment;filename="+fileInfo.FullName);

Please suggest how can I get to that file and give it to the response header so that it could be downloaded.

Answer Source

using the path in below format fixed the issue -


suggested by @avijit

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download