コード例 #1
0
ファイル: MainWindow.cs プロジェクト: fenriv/NetOpen
        /// <summary>
        /// Geting shares, and looking at them :::))))
        /// </summary>
        public void Rem_share()
        {
            string server = pcList.FocusedItem.ToolTipText;

            if (server != null && server.Trim().Length > 0)
            {
                Temp tmp = new Temp();
                tmp.Show();
                tmp.rtb.Text += "\nShares on "+server+"\n";
                ShareCollection shi = ShareCollection.GetShares(server);
                if (shi != null)
                {
                    foreach (Share si in shi)
                    {
                        if (si.ShareType.ToString() == "Disk") tmp.rtb.Text += si.ShareType + " " + si + " " + si.Root.Exists.ToString() +"\n";

                        //Определяем доступны ли росшары
                        /*if (si.IsFileSystem)
                        {
                            try
                            {
                                System.IO.DirectoryInfo d = si.Root;
                                System.IO.DirectoryInfo[] Flds = d.GetDirectories();
                            }
                            catch (Exception ex)
                            {
                                tmp.rtb.Text += "\tError listing:" + si.ToString() + "\n\t" + ex.Message + "\n";
                            }
                        }*/
                    }
                }
                else
                    tmp.rtb.Text += "Unable to enumerate the shares on" + server + ".\n"
                        + "Make sure the machine exists, and that you have permission to access it.\n\n";
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: fenriv/NetOpen
        /// <summary>
        /// Geting shares, and looking at them :::))))
        /// </summary>
        public void Rem_share()
        {
            string server = pcList.FocusedItem.ToolTipText;

            if (server != null && server.Trim().Length > 0)
            {
                Temp tmp = new Temp();
                tmp.Show();
                tmp.rtb.Text += "\nShares on "+server+"\n";
                ShareCollection shi = ShareCollection.GetShares(server);
                if (shi != null)
                {
                    foreach (Share si in shi)
                    {
                        if (si.ShareType.ToString()=="Disk")tmp.rtb.Text += si.ShareType + " " + si + " " + si.Path + "\n";

                        // If this is a file-system share, try to
                        // list the first five subfolders.
                        // NB: If the share is on a removable device,
                        // you could get "Not ready" or "Access denied"
                        // exceptions.
                        // If you don't have permissions to the share,
                        // you will get security exceptions.

                        //Определяем доступны ли росшары
                        /*if (si.IsFileSystem)
                        {
                            try
                            {
                                System.IO.DirectoryInfo d = si.Root;
                                System.IO.DirectoryInfo[] Flds = d.GetDirectories();
                            }
                            catch (Exception ex)
                            {
                                tmp.rtb.Text += "\tError listing:" + si.ToString() + "\n\t" + ex.Message + "\n";
                            }
                        }*/
                    }
                }
                else
                    tmp.rtb.Text += "Unable to enumerate the shares on" + server + ".\n"
                        + "Make sure the machine exists, and that you have permission to access it.\n\n";
            }
        }