Question

Is there a way to search for a file on all available network shares without actually giving the search any info on the names of the sharing machines?

Here's what I'm trying to do. In a servers shared folder I have a configuration file that specifies the UNC info for that share. From another desktop on that LAN, I would like to run a program that searches for that file and maps a drive to that folder based on that files contents.

I have a staff of tech support folks that frequently have to map these drives to a shared folder. The people they are on the phone with can be very inexperienced with computers. I'm trying to find a way to make their job easier.

Thanks for any help offered.

Was it helpful?

Solution

I don't recall a Windows API for listing available network shares (though I may have missed it), but one quick (in code slow in processing) way to do this would be to use the method from this CodeProject article to discover the computers on the network (or at least most of them), and try to connect to @"\\" + currentIPOrHostName to see if you're able to get a share list back. I've never done it so I can't guarantee that it'll work but it would be worth a shot unless someone else comes up with a better way.

OTHER TIPS

Try this one (C# 4.0):

    private void ShowDrives()
    {
        DriveInfo[] drives = DriveInfo.GetDrives();
        foreach (DriveInfo drive in drives)
        {
            MessageBox.Show(drive.Name);
        }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top