private void btnOK_Click(object sender, EventArgs e) { safeFMName = ArchiveExtract.ArchiveExtracedFolderName(tbNewFolder.Text); string newFMFolder = FMsPath + "\\" + safeFMName; if (!Directory.Exists(newFMFolder)) { Directory.CreateDirectory(newFMFolder); DialogResult = DialogResult.OK; } else { MessageBox.Show(tbNewFolder.Text + " already exists."); } }
private void btnImportINI_Click(object sender, EventArgs e) { DialogResult dR = openDarkloaderINI.ShowDialog(); if (dR == DialogResult.OK) { //ini files INIFile oldINI = new INIFile(openDarkloaderINI.FileName); //Get sizes in bytes of each FM file List <string> foundFilesInArchivePaths = new List <string>(); foreach (string path in fmArchiveFullPaths) { foundFilesInArchivePaths.AddRange(Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)); } foreach (string file in foundFilesInArchivePaths) { FileInfo fI = new FileInfo(file); long sizeBytes = fI.Length; string ext = fI.Extension; string simpleFilename = fI.Name; string oldSectionName = simpleFilename; bool fmIsArchive = false; if (ext.Length != 0) { simpleFilename = fI.Name.Replace(ext, ""); oldSectionName = simpleFilename + "." + sizeBytes; fmIsArchive = true; } string newSectionName = "FM=" + ArchiveExtract.ArchiveExtracedFolderName(simpleFilename); string newNiceName = newINI.IniReadValue(newSectionName, nKeys.FMTitle); if (newNiceName == simpleFilename || newNiceName == "") { string oldNiceName = oldINI.IniReadValue(oldSectionName, "title").Replace("\"", ""); if (oldNiceName != "") { newINI.IniWriteValue(newSectionName, nKeys.FMTitle, oldNiceName); } } string newFinished = newINI.IniReadValue(newSectionName, nKeys.FinishedID); if (newFinished == "") { string oldFinished; if (fmIsArchive) { oldFinished = oldINI.IniReadValue(oldSectionName, "finished"); } else { oldFinished = oldINI.INIReadValueNoSize(oldSectionName, "finished"); } if (oldFinished != "") { newINI.IniWriteValue(newSectionName, nKeys.FinishedID, oldFinished); } } oldDateToNewDate(oldINI, newINI, oldSectionName, newSectionName, DateType.Release, fmIsArchive); oldDateToNewDate(oldINI, newINI, oldSectionName, newSectionName, DateType.LastPlayed, fmIsArchive); string newComment = newINI.IniReadValue(newSectionName, nKeys.Comment); if (newComment == "") { string oldComment; if (fmIsArchive) { oldComment = oldINI.IniReadValue(oldSectionName, "comment").Replace("\"", ""); } else { oldComment = oldINI.INIReadValueNoSize(oldSectionName, "comment").Replace("\"", ""); } if (oldComment != "") { newINI.IniWriteValue(newSectionName, nKeys.Comment, oldComment); } } } iniImported = true; //allows a property to report that the ini was imported so the main form can refresh the table. } }