本文介绍了为什么我得到未知错误1346?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我收到未知错误1346?



模拟代码后,我将从本地驱动器复制文件到网络驱动器时遇到异常1346。如果注释了相同的代码,则文件将被成功复制。我想在冒充之后做同样的事情。凭证和所有凭证都有效。



以下是我的代码:

  string  serverName = CheckUNCPath(  Z:); 
string username = @ Alexander.junior @ chn.nestgroup.net;

// string username =alexander.junior;
string password = [已删除] *;
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsIdentity identity = new WindowsIdentity(用户名,密码);
WindowsImpersonationContext context = identity.Impersonate();

string updir = serverName;
string destPath = @ D:\\ \\Alex_BackUp\Test\test1.txt;
File.Copy(destPath,updir, true );
解决方案





我知道您认为用户名和密码是正确的,但有些不对。也许他们没有足够的权限。也许用户名应该是domain \ username。不确定,但你必须在最后解决它。



Why I am getting unknown error 1346?

After the Impersonation code I am getting exception 1346 on copying file from a local drive to a network drive. If the same code is commented the file is getting copied successfully. I want to do the same after impersonation. The credentials and all are valid.

Below is my code:

 string serverName=CheckUNCPath("Z:");
 string username = @"[email protected]";

  //string username = "alexander.junior";
  string password = "[removed]*";
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsIdentity identity = new WindowsIdentity(username, password);
WindowsImpersonationContext context = identity.Impersonate();

string updir = serverName;
string destPath = @"D:\Alex_BackUp\Test\test1.txt";
File.Copy(destPath,updir,true);
解决方案



I know you think the username and password are correct, but something isn't right. Perhaps they don't have enough permissions. Perhaps username should be domain\username instead. Not sure, but you'll have to troubleshoot it on your end.



这篇关于为什么我得到未知错误1346?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 14:30