This project is read-only.

Create a new file storage

A new file storage using C#

When you are getting started with NFileStorage you ofcourse need to create the FileStorage itself. You can create and access any number of FileStorages at any time. A FileStorage is identified by a name, the so called FileStorageName. You can create a 'foobar' NFileStorage container like so

    var fileStorageName = "foobar";
    FileStorageFacade.Create(fileStorageName, CreateFileStorageBehaviour.ThrowExceptionWhenExists);

The second parameter specifies the behaviour of this method; in this case the program will throw an Exception if there's already a filestorage name existing with this name. The current set of behaviours is:

    public enum CreateFileStorageBehaviour

A new file storage using the CLI

Or you can use the CommandLine tool (CLI). If for example we want to create a FileStorage 'foobar' using the CLI this would look like:

H:\CLI>FileStorageCmd.exe new foobar
File storage foobar created
This operation took 29 msecs

The result

After the file storage is created, the system will have created two files on your file system; and foobar.FileStorage.index.fc.

H:\CLI>dir *.fc
 Volume in drive H is H
 Volume Serial Number is 9C3F-E01B

 Directory of H:\CLI

12-04-2009  19:15               100
12-04-2009  19:15             2.148 foobar.FileStorage.index.fc
               2 File(s)          2.248 bytes
               0 Dir(s)  30.980.329.472 bytes free


All right, that was easy, your first 'foobar' FileStorage :). You might wonder why there are 2 files; the index file will contain pointers to offsets in the data file, where-as the data file will contain the actual binary data we want to store.

Last edited Apr 12, 2009 at 6:18 PM by barkgj, version 7


No comments yet.