I want copy my file to another machine in network using c#.net. can any one please help me with it

thanks Swati ail

Use File.Copy(), it can recognize mapped drives as well as UNC paths.

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

        WindowsIdentity idnt = new WindowsIdentity("administrator","admin" );

        WindowsImpersonationContext context = idnt.Impersonate();
        context.Undo();

File.Copy(@"D:\filename.text", @"\192.168.2.14\temp\filename.text", true);

while personifing m getting error
"The name provided is not a properly formed account name."
why am i getting this error. I have given correct user name and password

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.