Пример #1
0
        /// <summary>
        /// Tests the specified map.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <returns></returns>
        public static bool Test(DriveMap map)
        {
            bool ret = true;

            ret = ret && Mount(map);
            ret = ret && Unmount(map);
            return(ret);
        }
Пример #2
0
        public void testMountDevice()
        {
            DriveMap map = new DriveMap();

            map.Drive    = "Z:";
            map.RealPath = @"127.0.0.1\c$";
            map.Password = "******";
            map.Username = @"TEST\TEST";

            Assert.IsTrue(DriveMapManager.Mount(map));
            Assert.IsTrue(DriveMapManager.Unmount(map));
            Assert.IsTrue(DriveMapManager.Test(map));
        }
Пример #3
0
        /// <summary>
        /// Applies the specified mapping.
        /// </summary>
        /// <param name="mapping">The mapping.</param>
        /// <returns></returns>
        public static bool Apply(DriveMap mapping)
        {
            bool bRet = false;

            if (mapping.Type == DriveMapType.MOUNT)
            {
                Unmount(mapping);
                bRet = Mount(mapping);
            }
            else
            {
                bRet = Unmount(mapping);
            }

            return(bRet);
        }
Пример #4
0
        /// <summary>
        /// Maps the specified mapping.
        ///
        ///
        /// </summary>
        /// <param name="mapping">The mapping.</param>
        /// <returns></returns>
        public static bool Mount(DriveMap mapping)
        {
            //net use z: \\127.0.0.1\c$  3dylan3dog3 /USER:insiel\908099 /PERSISTENT:NO

            String temp = "";

            if (mapping.Drive.Length > 0)
            {
                temp += mapping.Drive + " ";
            }

            if (mapping.RealPath.Length > 0)
            {
                string sTemp = mapping.RealPath.Trim();
                if (!sTemp.StartsWith(@"\\"))
                {
                    sTemp = @"\\" + sTemp;
                }

                temp += "" + sTemp + " ";
            }

            if (mapping.Username.Length > 0)
            {
                string pwd = mapping.Password;
                if (pwd != null)
                {
                    temp += pwd + " ";
                }
                temp += "/USER:"******" ";
            }

            temp += "/PERSISTENT:NO";

            return(WindowsExecutor.Execute("net", " use " + temp));
        }
Пример #5
0
 /// <summary>
 /// Unmounts the specified map.
 /// </summary>
 /// <param name="map">The map.</param>
 /// <returns></returns>
 public static bool Unmount(DriveMap map)
 {
     // net use /DELETE z:
     return(WindowsExecutor.Execute("net", " use /DELETE " + map.Drive));
 }
Пример #6
0
 public static DriveMap Copy(DriveMap obj)
 {
     return((DriveMap)obj.MemberwiseClone());
 }