The following code is available:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Security.Principal; using System.IO; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { string username = @"Abserv\r.ivanov"; // Нужно чтобы соединялось и через домен и без. string password = @"Blab"; string network_file_path = @"\\172.10.0.80\c$\test\test.txt"; string local_file_path = @"c:\test\test.txt"; AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); WindowsIdentity idnt = new WindowsIdentity(username, password); WindowsImpersonationContext context = idnt.Impersonate(); File.Copy(network_file_path, local_file_path, true); context.Undo(); } } } However, when executing this code, the error "The specified name is not correct" occurs:
What is the cause of this problem?
