public Stream CreateFile(string path) { string directoryPath = Path.GetDirectoryName(path); // Make sure the directories are created first. CreateDirectory(directoryPath); InMemoryDirectory directory = GetDirectory(directoryPath) as InMemoryDirectory; InMemoryFile file = new InMemoryFile(this, path); return directory.AddFile(file); }
public IFile GetFile(string path) { IFile file = null; IDirectory directory = GetDirectory(Path.GetDirectoryName(path)); if (directory.Exists) { string soughtFileName = Path.GetFileName(path).ToLower(); file = directory.GetFiles().SingleOrDefault(f => f.Name.ToLower() == soughtFileName); } // If the requested directory doesn't exist or the file isn't in the directory then // return a blank file (Exists == false) if (!directory.Exists || file == null) { file = new InMemoryFile(this, path); } return file; }