コード例 #1
0
        public DirectoryInMemory(DirectoryInfo directoryInfo, ILogger logger)
        {
            DirectoryInfo = directoryInfo;
            Logger        = logger;

            try
            {
                foreach (FileSystemInfo fileSystemInfo in DirectoryInfo.EnumerateFileSystemInfos())
                {
                    if (fileSystemInfo is DirectoryInfo subDirectoryInfo)
                    {
                        DirectoryInMemory directoryInMemory = new DirectoryInMemory(subDirectoryInfo, logger, this);
                        SubDirectories.Add(directoryInMemory);
                    }
                    else if (fileSystemInfo is FileInfo fileInfo)
                    {
                        FileInMemory fileInMemory = new FileInMemory(fileInfo, this);
                        Files.Add(fileInMemory);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogWarning($"Cannot read contents of \"{directoryInfo.FullName}\"", e);
            }
        }
コード例 #2
0
 internal void RemoveFile(FileInMemory fileInMemory)
 {
     Files.Remove(fileInMemory);
 }