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,177
  • 2
  • 18
  • 40

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
  • 212,447
  • 27
  • 392
  • 421