public void Delete(StorageIdentity identity) { var path = GetPath(identity); if (!File.Exists(path)) { throw new FileNotFoundException(); } File.Delete(path); }
public Stream Get(StorageIdentity identity) { var path = GetPath(identity); if (!File.Exists(path)) { throw new FileNotFoundException(); } return(File.OpenRead(path)); }
public IEnumerable <StorageIdentity> List(StorageIdentity identity) { return(Directory .EnumerateFiles(GetDirectory(identity)) .Select(file => new StorageIdentity { Id = Path.GetFileNameWithoutExtension(file), Name = identity.Name, Type = identity.Type })); }
public void Save(StorageIdentity identity, MemoryStream stream) { if (!Directory.Exists(GetDirectory(identity))) { Directory.CreateDirectory(GetDirectory(identity)); } var path = GetPath(identity); if (File.Exists(path)) { File.Delete(path); } using (var fs = File.OpenWrite(path)) { stream.WriteTo(fs); } }
private string GetFilename(StorageIdentity identity) { return(identity.Id + "." + fileEnding); }
private string GetDirectory(StorageIdentity identity) { return(savePath + identity.Name + Path.DirectorySeparatorChar); }
private string GetPath(StorageIdentity identity) { return(GetDirectory(identity) + GetFilename(identity)); }