Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- public static void Main(string[] args)
- {
- var domainName = "mydomainName";
- var userName = "myUser";
- var password = "MyPassword";
- var sharedFolder = @"\\MyFolder\";
- var sharedFile = @"\\MyFolder\\MyFile.pdf";
- Console.WriteLine("Step0 -> POC ImpersonationDemo");
- var crednzial = new NetworkCredential(userName, password, domainName);
- using (new NetworkConnection(sharedFolder, crednzial))
- {
- File.Delete(@"C:\Temp\a.pdf");
- File.Copy(sharedFile, @"C:\Test\Temp\a.pdf");
- }
- Console.ReadLine();
- }
- }
Add Comment
Please, Sign In to add comment