public Folder(string name, Folder parentFolder, SessionBase session) : base(name) { CompareByField<FileInDb> comparerByFileName = new CompareByField<FileInDb>("m_name", session, false, true); m_files = new BTreeSet<FileInDb>(comparerByFileName, session, 10000, CommonTypes.s_sizeOfUInt32); CompareByField<Folder> comparerByFolderName = new CompareByField<Folder>("m_name", session, false, true); m_subFolders = new BTreeSet<Folder>(comparerByFolderName, session, 10000, CommonTypes.s_sizeOfUInt32); if (parentFolder != null) { m_parentFolder = parentFolder; m_parentFolder.Folders.AddFast(this); } }
public void DoFileFolderTest() { using (SessionNoServer session = new SessionNoServer(s_systemDir)) { session.NotifyBeforeCommit = NotifyBeforeCommit; session.BeginUpdate(); DirectoryInfo dirInfo = new DirectoryInfo(s_sampleFolder); Folder folder = new Folder(dirInfo.Name, null, session); CreateDirectoriesAndFiles(dirInfo, folder, session); session.Persist(folder); session.Commit(); } }
void CreateDirectoriesAndFiles(DirectoryInfo dirInfo, Folder folder, SessionBase session) { foreach (DirectoryInfo dir in dirInfo.GetDirectories()) { Folder subFolder = new Folder(dir.Name, folder, session); CreateDirectoriesAndFiles(dir, subFolder, session); } foreach (FileInfo fileInfo in dirInfo.GetFiles()) { FileInDb file = new FileInDb(fileInfo.Name, folder); byte[] bytes = File.ReadAllBytes(fileInfo.FullName); FileContent fileContent = new FileContent(bytes); session.Persist(fileContent); file.Content = fileContent; } }
public FileInDb(string name, Folder parentFolder):base(name) { m_folder = parentFolder; m_folder.Files.AddFast(this); }