private static void ScanFiles(string path, BaseDataContainer curFolder) { // iterate over all files in the current directory // read information intoa SingleFileData and add it to projectData foreach (string filename in Directory.EnumerateFiles(path)) { // append loading progress AppendProgress(filename); // load file SingleFileData fileData = new SingleFileData(Path.GetFileName(filename), curFolder); TextFinder.TextFinder.FindText(filename, fileData.texts); if (fileData.texts.Count > 0) { curFolder.AddChild(fileData); } } // iterate over all directories and scan recursively foreach (string dirname in Directory.EnumerateDirectories(path)) { // append loading progress AppendProgress(dirname); // load folder FolderData folder = new FolderData(Path.GetFileName(dirname), curFolder); ScanFiles(dirname, folder); if (folder.children.Count > 0) { curFolder.AddChild(folder); } } }
private static void OpenTranslationProjectHelper(StreamReader reader, BaseDataContainer cur) { // append loading progress AppendProgress(cur.name); string line = reader.ReadLine(); while (line.Length != 0 && line[0] != '}') { if (line[0] == '{') { BaseDataElement file; // single file if (line[1] == '#') { file = new SingleFileData(line.Substring(2), cur); } // folder else { file = new FolderData(line.Substring(1), cur); } cur.AddChild(file); OpenTranslationProjectHelper(reader, file); } line = reader.ReadLine(); } }