async Task Init() { Stream fs = await fileSystem.OpenFile(fileName); this.stream.SetStream(fs, true); this.fsInfo = (IFileStreamInfo)fs; }
public async Task Update() { CheckDisposed(); if (fsInfo == null) { Stream fs; try { fs = await fileSystem.OpenFile(fileName); } catch { return; } this.stream.SetStream(fs, true); this.fsInfo = (IFileStreamInfo)fs; } if (fsInfo.IsDeleted) { size = 0; lastModified = new DateTime(); stream.SetStream(emptyMemoryStream, false); fsInfo = null; return; } size = stream.Length; lastModified = fsInfo.LastWriteTime; }
public SimpleFileMedia(IFileSystem fileSystem, IConnectionParams connectParams) { if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } this.fileSystem = fileSystem; this.fileName = connectParams[fileNameParam]; if (string.IsNullOrEmpty(fileName)) { throw new ArgumentException("Invalid or incomplete connection params"); } try { Stream fs = fileSystem.OpenFile(fileName); this.stream.SetStream(fs, true); this.fsInfo = (IFileStreamInfo)fs; Update(); } catch (Exception) { Dispose(); throw; } }