コード例 #1
0
        public static bool MapDrive(string drive, string folderShare, string userName, string password)
        {
            NetworkDrive netDrive = null;

            try
            {
                if (Directory.Exists(drive))
                {
                    return(true);
                }
                else
                {
                    netDrive            = new Network.NetworkDrive();
                    netDrive.LocalDrive = drive;
                    netDrive.ShareName  = folderShare;
                    netDrive.MapDrive(userName, password);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                T2P._2015.Cross.Utility.ExceptionHandling.ExceptionHelper.GetDetailMessageAndLog(ex);
                return(false);
            }
            finally
            {
                netDrive = null;
            }
        }
コード例 #2
0
        public static bool MapDrive(string drive, string folderShare, string workingFolder, string userName, string password)
        {
            NetworkDrive netDrive = null;

            try
            {
                if (Directory.Exists(drive))
                {
                    return(true);
                }
                else
                {
                    netDrive            = new Network.NetworkDrive();
                    netDrive.LocalDrive = drive;
                    netDrive.ShareName  = folderShare;
                    netDrive.MapDrive(userName, password);

                    if (Directory.Exists(workingFolder))
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                netDrive = null;
            }
        }
コード例 #3
0
        public static bool MapDrive(string drive, string folderShare)
        {
            NetworkDrive netDrive = null;

            try
            {
                netDrive            = new Network.NetworkDrive();
                netDrive.LocalDrive = drive;
                netDrive.ShareName  = folderShare;
                netDrive.MapDrive();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                netDrive = null;
            }
        }