Exemple #1
0
        private string Seek()
        {
            StringBuilder sb = new StringBuilder();

            #region intialize search
            CompEnum domainComputers;
            domainComputers = new CompEnum(CompEnum.ServerType.SV_TYPE_DOMAIN_ENUM, null);
            #endregion

            #region search domains
            CompEnum networkComputers;
            for (int i = 0; i < domainComputers.Length; i++)
            {
                networkComputers = new CompEnum((uint)CompEnum.ServerType.SV_TYPE_SERVER + (uint)CompEnum.ServerType.SV_TYPE_PRINTQ_SERVER, domainComputers[i].Name);
                #region search computer shares
                ShareCollection shi = null;
                for (int j = 0; j < networkComputers.Length; j++)
                {
                    shi = ShareCollection.GetShares(networkComputers[j].Name);

                    if (!shi.AccessDenied)
                    {
                        foreach (Share anyShare in shi)
                        {
                            if (!anyShare.NetName.Contains("$"))
                            {
                                switch (anyShare.ShareType)
                                {
                                case ShareType.Device:
                                    sb.AppendLine(string.Format("Network Folder:{0}", anyShare.Root.FullName));
                                    break;

                                case ShareType.Disk:
                                    sb.AppendLine(string.Format("Network Disk:{0}", anyShare.Root.FullName));
                                    break;

                                case ShareType.Printer:
                                    sb.AppendLine(string.Format("Network Printer:{0}", anyShare.Root.FullName));
                                    break;

                                case ShareType.IPC:
                                    sb.AppendLine(string.Format("Network IPC:{0}", anyShare.Root.FullName));
                                    break;

                                default:
                                    sb.AppendLine(string.Format("Network Default:{0}", anyShare.Root.FullName));
                                    break;
                                }
                            }
                        }
                    }
                }
                #endregion
            }
            #endregion
            return(sb.ToString());
        }
Exemple #2
0
 public ShareCollection GetSharesForComputer(string computerName)
 {
     return(ShareCollection.GetShares(computerName));
 }