public static void CopyTo(this FileInfo file, string computerName, string userName, string password, string remotePath = null) { using (RunAsContext runasContext = RunAs.Impersonate(userName, password)) { CopyTo(file, computerName, remotePath); } }
public void Dispose() { RunAs.UndoImpersonate(this); if (Context != null) { Context.Dispose(); } }