本文整理汇总了C#中KeePassLib.PwDatabase.Save方法的典型用法代码示例。如果您正苦于以下问题:C# PwDatabase.Save方法的具体用法?C# PwDatabase.Save怎么用?C# PwDatabase.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeePassLib.PwDatabase
的用法示例。
在下文中一共展示了PwDatabase.Save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateKeePassDatabase
public static PwDatabase CreateKeePassDatabase(string databasePath, CompositeKey compositeKey)
{
if (!databasePath.EndsWith(".kdbx"))
throw new FileNotFoundException("The database file must end with .kdbx");
var directoryName = Path.GetDirectoryName(databasePath);
var fileName = Path.GetFileName(databasePath);
if (!Directory.Exists(directoryName))
Directory.CreateDirectory(directoryName);
var ioc = new IOConnectionInfo();
ioc.Path = fileName;
ioc.CredSaveMode = IOCredSaveMode.NoSave;
var database = new PwDatabase();
database.New(ioc, compositeKey);
database.Save(null);
return database;
}
示例2: Save
public void Save(PwDatabase kpDatabase, Stream stream)
{
kpDatabase.Save(stream, null);
}
示例3: CloseKeePassDatabase
public static void CloseKeePassDatabase(PwDatabase database)
{
database.Save(null);
database.Close();
}
示例4: ShouldHandleCyclesOfNodesInImportAndExport
public void ShouldHandleCyclesOfNodesInImportAndExport()
{
var exportPath = GetTestPath();
m_syncManager.AddExportPath(exportPath);
var userMrX = TestHelper.GetUserRootNodeByNameFor(m_database, "mrX");
m_database.GetExportGroup().Groups.GetAt(0).AddEntry(PwNode.CreateProxyNode(userMrX), true);
var existingEntry = new PwEntry(true, true);
existingEntry.SetTitle("Entry Version 1");
m_database.RootGroup.AddEntry(existingEntry, true);
m_database.RootGroup.AddEntry(PwNode.CreateProxyNode(userMrX), true);
m_treeManager.CorrectStructure();
string exportFile = exportPath + SyncSource.FileNameFor(userMrX) + SyncExporter.FileExtension;
Assert.IsFalse(File.Exists(exportFile));
m_syncManager.Export();
var deltaDBInitial = new PwDatabase();
deltaDBInitial.Open(IOConnectionInfo.FromPath(exportFile), m_standardKey, null);
Assert.AreEqual(1, deltaDBInitial.RootGroup.GetEntries(true).Count(e => e.GetTitle() == "Entry Version 1"));
foreach(var entry in deltaDBInitial.RootGroup.GetEntries(true))
{
entry.SetTitle("Changed");
}
deltaDBInitial.Save(null);
deltaDBInitial.Close();
m_syncManager.AddImportPath(exportFile);
m_database.GetImportGroup().Groups.GetAt(0).Entries.GetAt(0).SetPassword(userMrX.Strings.ReadSafe(KeeShare.KeeShare.PasswordField));
m_syncManager.RefeshSourcesList();
// Node normalEntry6 is within the user home and is relocated on export which changes the parent node - during import, the parents of
// not "officially" relocated nodes is checked and an assertion is thrown
Assert.AreEqual(0, m_database.RootGroup.GetEntries(true).Count(e => e.GetTitle() == "Changed"));
}