Ejemplo n.º 1
0
        async Task Init()
        {
            Stream fs = await fileSystem.OpenFile(fileName);

            this.stream.SetStream(fs, true);
            this.fsInfo = (IFileStreamInfo)fs;
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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;
            }
        }