/// <summary> /// Constructor to load the specified Btrieve File at the given Path /// </summary> /// <param name="fileName"></param> /// <param name="path"></param> public BtrieveFileProcessor(string fileName, string path) { _fileFinder = DependencyInjection.ServiceResolver.GetService <IFileUtility>(); if (string.IsNullOrEmpty(path)) { path = Directory.GetCurrentDirectory(); } if (!Path.EndsInDirectorySeparator(path)) { path += Path.DirectorySeparatorChar; } LoadedFilePath = path; LoadedFileName = _fileFinder.FindFile(path, fileName); //If a .EMU version exists, load it over the .DAT file var jsonFileName = LoadedFileName.ToUpper().Replace(".DAT", ".EMU"); if (File.Exists(Path.Combine(LoadedFilePath, jsonFileName))) { LoadedFileName = jsonFileName; LoadJson(LoadedFilePath, LoadedFileName); } else { LoadBtrieve(LoadedFilePath, LoadedFileName); SaveJson(); } //Ensure loaded records (regardless of source) are in order by their offset within the Btrieve file LoadedFile.Records = LoadedFile.Records.OrderBy(x => x.Offset).ToList(); //Set Position to First Record Position = LoadedFile.Records.OrderBy(x => x.Offset).FirstOrDefault()?.Offset ?? 0; }