Exemple #1
0
 public static bool Delete(string dbFileName, Guid id)
 {
     using (FileDB db = new FileDB(dbFileName, FileAccess.ReadWrite))
     {
         return db.Delete(id);
     }
 }
Exemple #2
0
		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 />");
				}
			}
			
		}
Exemple #3
0
 public static void Export(string dbFileName, string directory, string filePattern)
 {
     using (FileDB db = new FileDB(dbFileName, FileAccess.Read))
     {
         db.Export(directory, filePattern);
     }
 }
Exemple #4
0
 public static EntryInfo Store(string dbFileName, string fileName, Stream input)
 {
     using (FileDB db = new FileDB(dbFileName, FileAccess.ReadWrite))
     {
         return db.Store(fileName, input);
     }
 }
Exemple #5
0
 public static void Shrink(string dbFileName)
 {
     using (FileDB db = new FileDB(dbFileName, FileAccess.Read))
     {
         db.Shrink();
     }
 }
Exemple #6
0
 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);
 }
Exemple #7
0
 public static EntryInfo Read(string dbFileName, Guid id, string fileName)
 {
     using (FileDB db = new FileDB(dbFileName, FileAccess.Read))
     {
         return db.Read(id, fileName);
     }
 }
Exemple #8
0
 public static EntryInfo Read(string dbFileName, Guid id, Stream output)
 {
     using (FileDB db = new FileDB(dbFileName, FileAccess.Read))
     {
         return db.Read(id, output);
     }
 }
Exemple #9
0
 public static EntryInfo[] ListFiles(string dbFileName)
 {
     using (FileDB db = new FileDB(dbFileName, FileAccess.Read))
     {
         return db.ListFiles();
     }
 }