0

I am writing a program in C# that needs to access certain files on my network. However on certain computers the users password and username is not saved and therefore the network cannot be accessed till they enter their credentials. Also, on certain computers we must map the network to drive before it can even get accessed.

How can I write a program, that the popup which would normally appear when accessing a network will still appear, allowing the user to enter his credentials and for my C# to not crash. Also if there is a work around to the map network drive it would be appreciated as well.

JabberwockyDecompiler
  • 3,318
  • 2
  • 42
  • 54
Sacha
  • 9
  • 1
    I would really hate to give you advice when you've already tried it so why don't you let us know what you've tried and what doesn't work with your attempts. – Neil Smith Jul 16 '14 at 20:22
  • All I have tried is to access the folder, e.g. "\\Sacha_Server\Documents" . I have no clue where to begin to enter in credentials. – Sacha Jul 16 '14 at 20:32
  • See http://stackoverflow.com/questions/295538/how-to-provide-user-name-and-password-when-connecting-to-a-network-share/1197430#1197430 – Tsukasa Jul 16 '14 at 20:45

1 Answers1

0

Your .exe will by default use the running users credentials, the credentials of the user are configurable via the current thread of execution.

Thread.CurrentPrincipal.Identity can be configured with the credentials of any valid user.

T McKeown
  • 12,971
  • 1
  • 25
  • 32