2

I have a wpf application that needs to write a file (from Byte[]) to a share on a server. I have a service account with permission to that share. Is there a way to do something like:

File.WriteAllBytes(path,bytes,username,password)?

Obviously that doesn't exist but my research has not turned up any answer.

LCaraway
  • 1,257
  • 3
  • 20
  • 48
  • Also http://stackoverflow.com/questions/17786037/copy-files-with-authentication-in-c-sharp – Jim W Jan 26 '17 at 20:56

1 Answers1

1

You to impersonate the other user and then write the file.

See: WindowsImpersonationContext made easy

Also check this answer for impersonation.

Community
  • 1
  • 1
Habib
  • 219,104
  • 29
  • 407
  • 436