File Path Collection

image_pdfimage_print

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections.ObjectModel;

public class FilePathCollection : Collection
{
public FilePathCollection Combine(string prefix)
{
FilePathCollection res = new FilePathCollection();

foreach (string s in this)
res.Add(Path.Combine(prefix, s));

return res;
}

public long GetTotalFileSize()
{
long res = 0;

for(int i = 0; i < this.Count; i++) { string current = this[i]; if (System.IO.File.Exists(current)) { FileInfo fi = new FileInfo(current); res += fi.Length; } else { this.RemoveAt(i); i--; } } return res; } } [/csharp]

This entry was posted in File Stream. Bookmark the permalink.