Introduction
NetworkSelect
is a control library that allows you to browse through the Network Neighborhood. It is possible to select the level of download, from domains, down to shares, directories, and files. The control will ask for a user name and password if a computer cannot be accessed.
Credits
This control is based on the excellent work of Richard Deeming (CodeProject member ID:34187) and Marc Merritt (member ID: 2851). They both provided some means to access network shares, and I've included (parts of) their classes in this project. Despite their good work, I still did not have some user-friendly way to browse through the Network Neighborhood, and that's how this control got created.
Using the code
The control code spreads a larger number of pages, so allow me not to go too deep into the details of the class itself.
In its simplest form, the control is used pretty straightforward.
- Step 1 Expand the NetworkSelect.zip file.
- Step 2 Create a new C# project in the same folder.
- Step 3 During development, you'd probably like to copy the images folder to your bin\Debug and bin\Release folders. The application expects that this images folder be present in the current application directory.
- Step 4 When opening the new project, add the following "Existing files" to your project:
- AskPassword.cs
- CompEnum.cs
- NetworkSelect.cs
- Shares.cs
Then perform a "Build Solution" to add the control to your project.
- Step 5 Draw the
NetworkSelect
control in the Form1
. Add a Button
, button1
, to the form.
- Step 6 Add the following
using
clause in the header of your program: using TIData.NetworkSelect;
- Step 6 Add the following
button1_Click
method to your program: private void button1_Click(object sender, System.EventArgs e)
{
networkSelect1.SeekThroughDomains(
NetworkSelect.HIDE_CHECKBOXES,
NetworkSelect.SHOW_SHARES,
NetworkSelect.SHOW_HIDDENSHARES,
NetworkSelect.SHOW_DIRECTORIES,
NetworkSelect.SHOW_FILES);
}
- Step 7 The domains, computers, shares, ..., files can be extracted using the following methods:
string myDomain = networkSelect1.GetCurrentDomain();
string myComputer = networkSelect1.GetCurrentComputer();
string myShare = networkSelect1.GetCurrentShare();
string myDir = networkSelect1.GetCurrentDirectory();
string myFile = networkSelect1.GetCurrentFile();
string fullPath = networkSelect1.GetFullName();
Finally, all the rest is for you...
A few notes
Regrettably, browsing through the Network can be a time consuming task. This is certainly the case whenever you don't have full rights to all domain computers. Therefore, the control shows a "Working hard for you, please wait..." message when enumerating domains, servers, ... files.
Although you can enable check boxes, I haven't included a method to read the checked paths. Hey, this is the very first release: 0.90. Shouldn't take too much time. Leave me a note if you badly need it.
I already know that the control shows up with a few Warnings too much. Will be fixed in the next release. The good thing is that it also shows a pop-up asking for a username/password whenever you don't manage to view the shares of a computer.
Version History
Not much of a history. This is the first release. Let's call it V0.9.0.