public DownloadContext(string FilePath) { FileInfo = new FileInfo(FilePath); if (FileInfo.Exists) { CurrentStream = FileInfo.OpenWrite(); StartBytes = CurrentStream.Length; CurrentStream.Seek(StartBytes, SeekOrigin.Current); } else { CurrentStream = FileInfo.Create(); } }
protected override void SetFileStream(string path, bool newFile, long fileSizeInBytes, long startingPosition) { const int bufferSize = 2 << 11; CurrentStream = UnbufferedStream.Get( path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, bufferSize); CurrentStream.Seek(startingPosition, SeekOrigin.Current); if (!newFile) { return; } CurrentStream.SetLength(fileSizeInBytes); Flush(); }