0

I'm trying to create an XML in an UNC path, using C#, but I'm getting the error "Access denied".

What I'm trying to do is:

doc.Save(@"\\someshare\somefolder\anotherfolder");

(the rest of the code is correct, I already tried on a local folder)

I guess I'll need to use some class to authenthicate on the share. But I don't know which. Could you tell me which is?

Andre Roque
  • 503
  • 1
  • 9
  • 31
  • The account the application is running under doesn't have write permission on the share. – David Crowell May 19 '14 at 14:54
  • I know that, what I need to know is what should I do, so I can give permissions to the application – Andre Roque May 19 '14 at 14:55
  • Are you able to access the folder from explorer? If so, is your app running under different permissions / user? Is it running as a service? – LB2 May 19 '14 at 14:55
  • In Explorer yes, I can access the folder. My application right now is running in Visual Studio with default credentials – Andre Roque May 19 '14 at 14:56
  • Does it work if you launch it outside the Visual Studio (i.e. from explorer)? If so, then it sounds like your VS is in a different security context, and instead of fixing code you may need to check how you launch Visual Studio. – LB2 May 19 '14 at 15:00
  • even after "Release" the application and running under an user that have permissions, give me the same error. Can't I use some class to "give" those credentials – Andre Roque May 19 '14 at 15:03
  • [This MSDN Social post](http://social.msdn.microsoft.com/forums/vstudio/en-US/dbde3b10-8644-4ba4-99f5-50d3df83245c/problems-authenticating-to-access-network-file-share) may be of help, but this may be [an XY Problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) since you shouldn't need to deal with credentials if process is running in user context that already has share access. I suspect that something else is going on that is causing the misbehavior. – LB2 May 19 '14 at 15:14
  • You say that you can access the share in Explorer, but can you write to it? (In other words, do you just have write permission for the share, or just read permission?) – John May 19 '14 at 15:59

0 Answers0