I had developed C# windows application. OS is Windows 7
Requirement: is to access Network Shared Folder ‘Test’ using code with credentials using W
I had the same problem when I used to deploy my C# project in IIS 7.5, but it's amazing when I do to removed the logout procedure of my code. . .
What I mean is removed function LogoutFromShare(ip,folder)
server directory.
I use ony this one LoginToOtherPC(ip, usr, pwd, folder)
.
By design, connecting to a share requires access to the share - it does not require access to the root directory of the share.
Opening the share via the Run box opens the root directory of the share, so it requires at least read access to the directory as well as to the share. The WNetAddConnection2() API, by comparison only requires access to the share.
It has to work this way, because it is sometimes desirable to give someone access to only certain subdirectories, but not the root directory. If connecting to the share required access to the root directory this would not be possible.
After connecting to the share, you can test access to the root directory by attempting to enumerate the files. If you get an access denied exception, the user does not have access.