private void AssembleFile(int FileId) { var segments = queue.Where(q => q.FileID == FileId).OrderBy(q => q.Number); string filename = segments.First().Filename; bool broken = segments.Any(s => s.Status == JobStatus.Failed); if (broken) { filename = filename.ToUpper(); } string path = Path.Combine(CompletedDirectory.FullName, filename); using (FileStream file = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None)) { foreach (var segment in segments) { if (segment.Status == JobStatus.Complete) { using (FileStream part = new FileStream(segment.CacheLocation, FileMode.Open, FileAccess.Read, FileShare.None)) { if (segment.ByteOffset > -1) { file.Position = segment.ByteOffset; } part.CopyTo(file); } File.Delete(segment.CacheLocation); } } } assembled[FileId] = true; FileCompleted(this, new FileCompletedEventArgs(path, broken)); if (assembled.All(f => f.Value)) { CacheDirectory.Delete(true); QueueCompleted(this, System.EventArgs.Empty); } }
public void ClearCache() { CacheDirectory.Delete(true); CacheDirectory.Create(); }
public void ClearCache() { CacheDirectory.Delete(true); InitChildDirectory(CACHE_DIR); }
public void Clear() => CacheDirectory.Delete(true);