views:

199

answers:

2

Here is the scenario:

There is a file on the network I'd like my program to have access to. They haven't authenticated on the network when they run my software, so accessing the file fails.

If I have the user open up explorer and manually navigate to the network path, they get asked by windows for their credentials, and from then on, whenever my software tries to access the file, it works fine.

So, is there a way I can say "Open this file, and its okay to ask the user for a password if that will help"?

Obviously, getting them to open explorer is not the best solution :)

A: 

This might help you out.

BFree
+2  A: 

You want the Windows API function WNetAddConnection3, which is straightforward to call through P/Invoke. Pass the CONNECT_INTERACTIVE flag.

Sunlight