public bool RemovePassword(string host, string username)
        {
            if (this._objectAlreadyDisposed)
            {
                throw new ObjectDisposedException("CredentialStore");
            }
            bool flag = false;

            if (File.Exists(this._credentialFilePath))
            {
                FileStream fileStream = (FileStream)null;
                try
                {
                    fileStream = this.OpenFile(FileShare.None);
                    XmlDocument credentialsXmlDocument = this.LoadCredentialsDocument((Stream)fileStream);
                    XmlNode     credentialNode         = CredentialStore.GetCredentialNode(credentialsXmlDocument, host, username, this._isUsernameCaseSensitive);
                    flag = credentialNode != null;
                    if (credentialNode != null)
                    {
                        credentialsXmlDocument.SelectSingleNode("/Credentials").RemoveChild(credentialNode);
                        CredentialStore.SaveCredentialsDocument(credentialsXmlDocument, (Stream)fileStream);
                    }
                }
                finally
                {
                    if (fileStream != null)
                    {
                        fileStream.Dispose();
                    }
                }
            }
            return(flag);
        }
        public bool AddPassword(string host, string username, char[] password)
        {
            if (this._objectAlreadyDisposed)
            {
                throw new ObjectDisposedException("CredentialStore");
            }
            if (string.IsNullOrEmpty(host))
            {
                throw new ArgumentException("Host name cannot be empty.", "host");
            }
            if (string.IsNullOrEmpty(username))
            {
                throw new ArgumentException("User name cannot be empty.", "username");
            }
            if (password == null)
            {
                password = new char[0];
            }
            FileStream fileStream = (FileStream)null;
            bool       flag;

            try
            {
                if (!File.Exists(this._credentialFilePath))
                {
                    using (File.Create(this._credentialFilePath, 8192, FileOptions.RandomAccess, CredentialStore.GetSecuritySettings()))
                        ;
                    fileStream = this.OpenFile(FileShare.None);
                    CredentialStore.InitializeCredentialsDocument((Stream)fileStream);
                }
                else
                {
                    fileStream = this.OpenFile(FileShare.None);
                }
                XmlDocument credentialsXmlDocument = this.LoadCredentialsDocument((Stream)fileStream);
                XmlNode     xmlNode = CredentialStore.GetCredentialNode(credentialsXmlDocument, host, username, this._isUsernameCaseSensitive);
                flag = xmlNode == null;
                if (xmlNode == null)
                {
                    xmlNode = (XmlNode)credentialsXmlDocument.CreateElement("passwordEntry");
                }
                else
                {
                    xmlNode.RemoveAll();
                }
                CredentialStore.FillCredentialNode(xmlNode, host, username, password);
                Array.Clear((Array)password, 0, password.Length);
                credentialsXmlDocument.SelectSingleNode("/Credentials").AppendChild(xmlNode);
                CredentialStore.SaveCredentialsDocument(credentialsXmlDocument, (Stream)fileStream);
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Dispose();
                }
            }
            return(flag);
        }
        private static char[] GetPasswordInternal(XmlDocument credentialsXmlDocument, string host, string username, bool isUsernameCaseSensitive)
        {
            char[]  chArray        = (char[])null;
            XmlNode credentialNode = CredentialStore.GetCredentialNode(credentialsXmlDocument, host, username, isUsernameCaseSensitive);

            if (credentialNode != null)
            {
                chArray = CredentialStore.DecryptPassword(credentialNode["password"].InnerText);
            }
            return(chArray);
        }