public void WriteFile(string filePath, Func <Stream> fileContentStream)
        {
            int index = filePath.IndexOf(DirectorySeparator, StringComparison.Ordinal);

            if (index == -1)
            {
                VirtualFileSystemFile file = new VirtualFileSystemFile(filePath, fileContentStream);
                AddFile(file);
                return;
            }
            string subDirectory         = filePath.Substring(0, index);
            string subDirectoryFilePath = filePath.Substring(index + DirectorySeparator.Length,
                                                             filePath.Length - index - DirectorySeparator.Length);
            var existingSubDirectory = _directories.SingleOrDefault(d => d.Name == subDirectory);

            if (existingSubDirectory == null)
            {
                existingSubDirectory = new VirtualFileSystemDirectory(subDirectory);
                AddDirectory(existingSubDirectory);
            }
            existingSubDirectory.WriteFile(subDirectoryFilePath, fileContentStream);
        }
 public void WriteFile(string filePath, Func<Stream> fileContentStream)
 {
     int index = filePath.IndexOf(DirectorySeparator, StringComparison.Ordinal);
     if (index == -1)
     {
         VirtualFileSystemFile file = new VirtualFileSystemFile(filePath, fileContentStream);
         AddFile(file);
         return;
     }
     string subDirectory = filePath.Substring(0, index);
     string subDirectoryFilePath = filePath.Substring(index + DirectorySeparator.Length,
         filePath.Length - index - DirectorySeparator.Length);
     var existingSubDirectory = _directories.SingleOrDefault(d => d.Name == subDirectory);
     if (existingSubDirectory == null)
     {
         existingSubDirectory = new VirtualFileSystemDirectory(subDirectory);
         AddDirectory(existingSubDirectory);
     }
     existingSubDirectory.WriteFile(subDirectoryFilePath, fileContentStream);
 }
 public void AddDirectory(VirtualFileSystemDirectory directory)
 {
     _directories.Add(directory);
 }
 public void AddDirectory(VirtualFileSystemDirectory directory)
 {
     _directories.Add(directory);
 }