This project is read-only.

File Warehouse is a abstractions for storing files.

Supported platforms:

  • Azure table storage
  • Desktop (.NET 4.5.1)

Installation

Core library (interfaces only)

PM> Install-Package FileWarehouse

Azure implementation:

PM> Install-Package FileWarehouse.Azure

Desktop implementation:

PM> Install-Package FileWarehouse.Desktop

Windows example

 // Connect to storage and get list of containers
IStorage storage = new DesktopStorage(storagePath);

// Create new or get existing container
IStorageContainer container = await storage.CreateOrGetContainerAsync("MyContainer"ContainerPermission.Private, failIfExists: false);

// Write content to a file
using (var memStream = new MemoryStream()) {
    using (var writer = new StreamWriter(memStream)) {
        writer.Write(content);
        writer.Flush();
        memStream.Position = 0;
    }

    await container.WriteAsync(memStream, fileName);
}

// Read file content from the container
using (Stream stream = await container.ReadAsync(fileName)) {
    var buffer = new byte[stream.Length];
    await stream.ReadAsync(buffer, 0, (int)stream.Length);
    result = Encoding.UTF8.GetString(buffer);
}

// Delete a file
await container.DeleteAsync(fileName);

// Get files list
IEnumerable<string> files = await container.GetFilesAsync(""StorageSearchOption.Default);

Azure Table Storage example

 // Connect to Azure storage and use same code as above
IStorage storage = new AzureStorage("ConnectionStringName");

Last edited Sep 12, 2014 at 3:40 AM by AndreyDotNet, version 6