Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Copy File on the Network using C#
WhatsApp
Mukesh Kumar
Oct 01
2015
8.6
k
0
0
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
IntPtr token;
LogonUser(
"username"
,
"domain"
,
"password"
, LogonType.LOGON32_LOGON_BATCH, LogonProvider.LOGON32_PROVIDER_DEFAULT);
WindowsIdentity identity =
new
WindowsIdentity(token);
WindowsImpersonationContext context = identity.Impersonate();
try
{
File.Copy(@
"c:\temp\MyFile.txt"
, @
"\\server\folder\Myfile.txt"
,
true
);
}
finally
{
context.Undo();
}
C#
Copy File on the Network
Up Next
Copy File on the Network using C#