Ejemplo n.º 1
0
        private async void restartDisk_Click(object sender, EventArgs e)
        {
            try
            {
                WshNetwork network     = new WshNetwork();
                Ping       pngSERV     = new Ping();
                PingReply  replictSERV = await pngSERV.SendPingAsync(addressSERV);

                if (replictSERV.Status == IPStatus.Success)
                {
                    //поиск сетевого диска
                    foreach (DriveInfo d in DriveInfo.GetDrives())
                    {
                        if (d.DriveType == DriveType.Network && d.Name == "Z" + @":\")
                        {
                            network.RemoveNetworkDrive("Z:", true, true); //Отключение найденного сетевого диска
                        }
                    }
                    //Подключение сетевого диска
                    object save = false;
                    object user = "******", pass = "******";
                    network.MapNetworkDrive("Z:", @"\\10.7.0.1\share500gb", ref save, ref user, ref pass);
                }
                else
                {
                    XtraMessageBox.Show("Сервер не доступен! Проверьте подключение VPN!");
                }
            }
            catch (Exception)
            {
                XtraMessageBox.Show("Сервер не доступен! Проверьте подключение VPN!");
            }
        }
Ejemplo n.º 2
0
        public void MapNetworkDrive(string driveLetter, string path)
        {
            IWshNetwork wshn = new WshNetwork();

            try
            {
                try
                {
                    object missingArgument = Type.Missing;
                    wshn.MapNetworkDrive(driveLetter, path, ref missingArgument, ref missingArgument, ref missingArgument);
                }
                catch (Exception ex)
                {
                    // Ignore unc path
                    editNarrative.AppendText(string.Format("\r\n\r\nHMRCFilingService: Error mapping drive {0} to {1}\r\n{2}", driveLetter, path, ex.Message));
                }
            }
            finally
            {
                wshn = null;
            }
        }
Ejemplo n.º 3
0
 public static void MapNetworkDrive(String local, String remote)
 {
     WshNetwork net = new WshNetwork();
     net.MapNetworkDrive(local, remote);
 }