The requested page is not available for the requested platform. You are viewing the content for Default platform.

IFileProvider Interface

Serves as a base interface that defines options to create custom file system providers.

Namespace: DevExtreme.AspNet.Mvc.FileManagement

Assembly: DevExtreme.AspNet.Core.dll

Declaration

public interface IFileProvider

Remarks

This examples shows how to use the IFileProvider interface to get and process data from a database in the File Manager in a custom way.

public class DbFileProvider : IFileProvider {
    ArtsDBContext DataContext { get; }
    public DbFileProvider(ArtsDBContext _context) {
        DataContext = _context;
    }
    public void Copy(string sourceKey, string destinationKey) {
        Arts sourceItem = GetDbItemByFileKey(sourceKey);
        Arts targetItem = GetDbItemByFileKey(Path.GetDirectoryName(destinationKey));
        if (targetItem.Id == sourceItem.ParentId)
            throw new SecurityException("You can't copy to the same folder.");
        List<Arts> childItems = DataContext.Arts.Where(p => p.ParentId == targetItem.Id).ToList();
        if (childItems.Select(i => i.Name).Contains(sourceItem.Name))
            throw new SecurityException("The folder contains an item with the same name.");
        CopyFolderInternal(sourceItem, targetItem);
    }
    public void CreateDirectory(string rootKey, string name) {
        // your code
    }

    public IList<IClientFileSystemItem> GetDirectoryContents(string dirKey) {
        // your code
    }
    public void Move(string sourceKey, string destinationKey) {
        // your code
    }
    //...
}

Online Demo: File Manager - Binding to Entity Framework

Online Example: File Manager - How to connect to a database using IFIleSystemProvider

See Also