Click here to Skip to main content
16,016,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working on a VB6 to c# migration project. The vb6 code uses 'NetShareEnum' method of netapi32.dll to get shared folders from a machine.

I have used the System.Management.ManagementClass to get the same in c#.

It works fine for the local machine, but when I try to get the shared folders of another machine in my local network, throws an UnauthorizedAccessException.

But the NetShareEnum works fine for other machines too. The vb6 code calls this method passing a value of 2 for the parameter dwLevel and get an access denied error (for another machine) and then call the same method passing a 1 for dwLevel.

Is there any way to achieve the same in c# than using the NetShareEnum. If I use the NetShareEnum, I need to pass a pointer and later convert the result to struct which is all so confusing for me.

Thanks in advance
Nishitha
Posted
Comments
[no name] 24-Apr-13 7:50am    
You can use P/Invoke or see if http://www.codeproject.com/Articles/2939/Network-Shares-and-UNC-paths helps you out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900