I used this code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
namespace Windo
I like this solution, because
public delegate void IntDelegate(int Int);
public static event IntDelegate FileCopyProgress;
public static void CopyFileWithProgress(string source, string destination)
{
var webClient = new WebClient();
webClient.DownloadProgressChanged += DownloadProgress;
webClient.DownloadFileAsync(new Uri(source), destination);
}
private static void DownloadProgress(object sender, DownloadProgressChangedEventArgs e)
{
if(FileCopyProgress != null)
FileCopyProgress(e.ProgressPercentage);
}
This should work with UNC paths as long as the permissions are set up. If not, you will get this error, in which case, I vote for the authenticated request user route.
System.UnauthorizedAccessException: Access to the path '\testws01\c$\foo' is denied.ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via
, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.