Voca (from previous post) - your method doesnt get the shared folders though... I already did something like that... but thanks... as I said I figured out what Im doing wrong and as a gift to you all here is a DLL that will make your lifes so much easier;
I put about 16 hours on this because its all API... and that meant a lot of Marshalling...pointers, and memory management; an example on how to use the code is below... as you can see I kept with the GetFiles(), GetDirectories() type of mentality and I even made its name space System.IO, please pass this on and if you use it, just credit me somewhere.
The zip file also has an XML file for the documentation. I did not build any error checking into this, so follow the instructions, but it is really common sense... also since it is all low level API on the inside if you screw up there is a possiblity of a memory leak... I went to great extremes to make sure to DeAllocate the memory that was in case of unexpected errors and in normal operation, in which case there is no need to worry, but still I want to put that warning out. I have tested this on my network at work which has hundreds of computers on it and everything worked great... remember to wait on the return on distance domains.... lag time people... to cause errors by exiting early because of lag time! I hope this helps many people, and when someone is searching for something to do this for four days (such as I was) I can save them some grief; let me know what you think!
Code Use Example:
[edit]Attachement removed - no binary files allowed in attachements. Please repost the attachement with soruce code if you wish. - mutant[/edit]
I put about 16 hours on this because its all API... and that meant a lot of Marshalling...pointers, and memory management; an example on how to use the code is below... as you can see I kept with the GetFiles(), GetDirectories() type of mentality and I even made its name space System.IO, please pass this on and if you use it, just credit me somewhere.
The zip file also has an XML file for the documentation. I did not build any error checking into this, so follow the instructions, but it is really common sense... also since it is all low level API on the inside if you screw up there is a possiblity of a memory leak... I went to great extremes to make sure to DeAllocate the memory that was in case of unexpected errors and in normal operation, in which case there is no need to worry, but still I want to put that warning out. I have tested this on my network at work which has hundreds of computers on it and everything worked great... remember to wait on the return on distance domains.... lag time people... to cause errors by exiting early because of lag time! I hope this helps many people, and when someone is searching for something to do this for four days (such as I was) I can save them some grief; let me know what you think!
Code Use Example:
C#:
SharedFolder [] folders = Network.GetSharedFolders(@"\\WILLYWONKASCOMPUTER");
int count = 0;
if(folders!=null)
{
foreach(SharedFolder s in folders)
{
Console.WriteLine(s.Name);
count++;
}
}
Console.WriteLine("Total Count = {0}", count);
Console.ReadLine();
[edit]Attachement removed - no binary files allowed in attachements. Please repost the attachement with soruce code if you wish. - mutant[/edit]
Last edited by a moderator: