Example #1
0
 /// <summary>
 /// Saves the given credential store to disk, overwriting an existing one.
 /// </summary>
 /// <param name="credentialStore">Credential store to save</param>
 private void saveCredentialStore(CredentialStore credentialStore)
 {
     // Prevent other threads from modifying the credential store while we're using it
     lock (credentialStoreLock)
     {
         // Create or truncate the credentials file
         using (FileStream fs = File.Open(CredentialStorePath, FileMode.Create, FileAccess.Write))
         {
             using (CodedOutputStream cos = new CodedOutputStream(fs))
             {
                 // Write the credential store to disk.
                 credentialStore.WriteTo(cos);
             }
         }
     }
 }
Example #2
0
        /// <summary>
        /// Saves the credential store to disk, overwriting an existing one.
        /// </summary>
        /// <param name="path">Credential store path</param>
        public void Save(string path)
        {
            lock (credentialStoreLock)
            {
                // Create or truncate the credentials file
                using (FileStream fs = File.Open(path, FileMode.Create, FileAccess.Write))
                {
                    using (CodedOutputStream cos = new CodedOutputStream(fs))
                    {
                        // Write the credential store to disk
                        credentialStore.WriteTo(cos);
                    }
                }

                RaiseLogEntry(new LogEventArgs(string.Format("Saved {0} credential{1}", credentialStore.Credentials.Count, credentialStore.Credentials.Count != 1 ? "s" : "")));
            }
        }