public static bool Delete(string dbFileName, Guid id) { using (FileDB db = new FileDB(dbFileName, FileAccess.ReadWrite)) { return db.Delete(id); } }
protected void Page_Load(object sender, EventArgs e) { using (FileDB db = new FileDB("c:\\data.fdb", System.IO.FileAccess.ReadWrite)) { db.Save("success.txt", Guid.NewGuid().ToString()); EntryInfo[] list = db.ListFiles(); for (int i = 0; i < list.Length; i++) { EntryInfo info = list[i]; Response.Write(db.Load(info)); Response.Write("<br />"); } } }
public static void Export(string dbFileName, string directory, string filePattern) { using (FileDB db = new FileDB(dbFileName, FileAccess.Read)) { db.Export(directory, filePattern); } }
public static EntryInfo Store(string dbFileName, string fileName, Stream input) { using (FileDB db = new FileDB(dbFileName, FileAccess.ReadWrite)) { return db.Store(fileName, input); } }
public static void Shrink(string dbFileName) { using (FileDB db = new FileDB(dbFileName, FileAccess.Read)) { db.Shrink(); } }
public void Shrink() { string dbFileName = this._fileStream.Name; FileAccess fileAccess = this._fileStream.CanWrite ? FileAccess.ReadWrite : FileAccess.Read; string tempFile = string.Concat(new object[] { Path.GetDirectoryName(dbFileName), Path.DirectorySeparatorChar, Path.GetFileNameWithoutExtension(dbFileName), ".temp", Path.GetExtension(dbFileName) }); if (File.Exists(tempFile)) { File.Delete(tempFile); } EntryInfo[] entries = this.ListFiles(); CreateEmptyFile(tempFile, false); using (FileDB tempDb = new FileDB(tempFile, FileAccess.ReadWrite)) { foreach (EntryInfo entry in entries) { using (MemoryStream stream = new MemoryStream()) { this.Read(entry.ID, stream); stream.Seek(0L, SeekOrigin.Begin); tempDb.Store(entry, stream); } } } this.Dispose(); File.Delete(dbFileName); File.Move(tempFile, dbFileName); this.Connect(dbFileName, fileAccess); }
public static EntryInfo Read(string dbFileName, Guid id, string fileName) { using (FileDB db = new FileDB(dbFileName, FileAccess.Read)) { return db.Read(id, fileName); } }
public static EntryInfo Read(string dbFileName, Guid id, Stream output) { using (FileDB db = new FileDB(dbFileName, FileAccess.Read)) { return db.Read(id, output); } }
public static EntryInfo[] ListFiles(string dbFileName) { using (FileDB db = new FileDB(dbFileName, FileAccess.Read)) { return db.ListFiles(); } }