2 using System
.Collections
.Generic
;
7 /// Gathers information on open shares in local area network.
9 internal class LanSpider
11 private static readonly string IndexFileName
= "index";
12 private static readonly string StateFileName
= "state";
15 private List
<string> _machines
;
23 _state
= new State( StateFileName
);
30 public void StartIndexing( )
39 private void DiscoverMachines( )
41 Console
.Write( "Loading list of computers in network ... " );
43 IEnumerable
<string> machines
= NetworkBrowser
.GetNetworkComputers( );
44 _machines
= new List
<string>( new[] {"EPUAKYIV01"}
);
46 Console
.WriteLine( "done." );
49 private void DiscoverShares( )
51 Queue
<string> shareQueue
= null;
53 Console
.Write( "Loading saved shares ... " );
54 if ( _machines
.Count
!= State
.MachinesCount
)
56 shareQueue
= new Queue
<string>( State
.GetMissingMachines( _machines
) );
59 Console
.WriteLine( "done." );
61 if ( shareQueue
!= null )
63 Console
.Write( "Loading {0} new shares ... ", shareQueue
.Count
);
64 foreach ( string machine
in shareQueue
)
66 IEnumerable
<string> shares
= NetworkBrowser
.GetShares( machine
);
67 foreach ( string share
in shares
)
69 State
.AddShare( String
.Format( @"\\{0}\{1}", machine
, share
) );
73 Console
.WriteLine( "done." );
77 private void IndexShares( )