public void TestExtract() { var far = new Far("test.far"); far.ParseFar(); far.Extract(); Assert.IsTrue(File.Exists("test.bmp")); // Assert the extracted file matches the file in the .far exactly using (var outFs = new FileStream("test.bmp", FileMode.Open, FileAccess.Read)) using (var farFs = new FileStream("test.far", FileMode.Open, FileAccess.Read)) { farFs.Seek(16, SeekOrigin.Begin); for (int i = 0; i < 144; i++) { Assert.AreEqual(farFs.ReadByte(), outFs.ReadByte()); } } File.Delete("test.bmp"); far.Extract(outputDirectory: "UIGraphics"); Assert.IsTrue(File.Exists(Path.Combine("UIGraphics", "test.bmp"))); Directory.Delete("UIGraphics", true); }
private void ExtractUigraphics(string pathToSimsExe) { var simsInstallationDirectory = Path.GetDirectoryName(pathToSimsExe); var uigraphicsPath = simsInstallationDirectory + @"\UIGraphics\UIGraphics.far"; log.Info($"Extracting images from {uigraphicsPath}"); if (!File.Exists(uigraphicsPath)) { MessageBox.Show($"Couldn't find UIGraphics.far at {uigraphicsPath}"); log.Info($"Couldn't find UIGraphics.far at {uigraphicsPath}"); } CreateDirectory(@"Content\UIGraphics"); var far = new Far(uigraphicsPath); var extractImages = new List <string>(images) { @"Downtown\largeback.bmp", @"Studiotown\dlgframe_1024x768.bmp", @"cpanel\Backgrounds\PanelBack.bmp" }; far.Extract(outputDirectory: @"Content\UIGraphics", filter: extractImages); }