private void MAPButtonClick(object sender, EventArgs e) { using (OpenFileDialog GenerateFor = new OpenFileDialog()) { GenerateFor.Filter = "All GB/C ROMs|*.gb;*.gbc"; if (GenerateFor.ShowDialog() == DialogResult.OK && File.Exists(GenerateFor.FileName)) { if ((new FileInfo(GenerateFor.FileName).Length / 1024) > 1024) { MessageBox.Show("ROM size exceeds the maximum of 1024kByte.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ROM ROMToProcess = new ROM(); using (FileStream FileToAdd = new FileStream(GenerateFor.FileName, FileMode.Open, FileAccess.Read)) { using (MemoryStream Mem = new MemoryStream()) { FileToAdd.CopyTo(Mem); ROMToProcess = Processing.ParseROM(Mem, GenerateFor.FileName); } } Byte[] MAPBytes = Processing.GenerateStandaloneMAPForROM(ROMToProcess); if (!CheckFolderPermissions(Path.GetDirectoryName(ROMToProcess.File))) { return; } String FileToCreate = Path.GetDirectoryName(ROMToProcess.File) + @"\" + Path.GetFileNameWithoutExtension(ROMToProcess.File) + ".map"; File.WriteAllBytes(FileToCreate, MAPBytes); MessageBox.Show("Created:" + Environment.NewLine + FileToCreate); } } }