Copy file from URI format path to local path
<p>I am trying to copy a file which is on a server and all I've got is it's URI format path.<br>
I've been trying to implement copying in C# .NET 4.5, but seems like CopyFile is not good with handling URI formats.<br>
So I've used IronPython with shutil, but seems like it is also not good with URI format paths.  </p>

<p>How do I get that file local?</p>

<pre><code>private string CopyFile(string from, string to, string pythonLibDir, string date)
{
    var dateTime = DateTime.Today;
    if (dateTime.ToString("yy-MM-dd") == date)
    {
       return "";
    }
    var pyEngine = Python.CreateEngine();
    var paths = pyEngine.GetSearchPaths();
    paths.Add(pythonLibDir);
    pyEngine.SetSearchPaths(paths);
    pyEngine.Execute("import shutil\n" +
                     "shutil.copyfile('" + from + "', '" + to + "')");
    return dateTime.ToString("yy-MM-dd");
}
</code></pre>

<p>I take all paths from xml config file.</p>

<p>you can use a webclient and then get the file on a particular folder.</p>

<pre><code>using (WebClient wc = new WebClient())
    wc.DownloadFile("http://sitec.com/web/myfile.jpg", @"c:\images\xyz.jpg");
</code></pre>

<p>or you can also use: <code>HttpWebRequest</code> inc ase you just want to read the content from a file from a server.</p>

<pre><code>var http = (HttpWebRequest)WebRequest.Create("http://sitetocheck.com");
var response = http.GetResponse();

var stream = response.GetResponseStream();
var sr = new StreamReader(stream);
var content = sr.ReadToEnd();
</code></pre>

c# python .net ironpython