pGina.Plugin.LocalMachine.LocalAccount.Connect2share C# (CSharp) Метод

Connect2share() приватный статический Метод

private static Connect2share ( string share, string username, string password, uint retry, System.Boolean DISconnect ) : System.Boolean
share string
username string
password string
retry uint
DISconnect System.Boolean
Результат System.Boolean
        private static Boolean Connect2share(string share, string username, string password, uint retry, Boolean DISconnect)
        {
            if (DISconnect)
            {
                m_logger.DebugFormat("Disconnect from {0}", share);
                if (!Abstractions.WindowsApi.pInvokes.DisconnectNetworkDrive(share))
                {
                    m_logger.WarnFormat("unable to disconnect from {0}", share);
                }

                return true;
            }
            else
            {
                string[] server = SMBserver(share, false);
                if (String.IsNullOrEmpty(server[0]))
                {
                    m_logger.ErrorFormat("Can't extract SMB server from {0}", share);
                    return false;
                }

                server[0] += "\\" + username;

                for (int x = 1; x <= retry; x++)
                {
                    try
                    {
                        m_logger.DebugFormat("{0}. try to connect to {1} as {2}", x, share, server[0]);
                        if (!Abstractions.WindowsApi.pInvokes.MapNetworkDrive(share, server[0], password))
                        {
                            m_logger.ErrorFormat("Failed to connect to share {0}", share);
                        }
                        if (Directory.Exists(share))
                        {
                            return true;
                        }
                        Thread.Sleep(new TimeSpan(0, 0, 30));
                    }
                    catch (Exception ex)
                    {
                        m_logger.Error(ex.Message);
                    }
                }

                return false;
            }
        }