private void CreateM3uFromResults(DataTable dt, string m3uFileName, ref OperationResult op) { try { if (dt == null || dt.Rows.Count < 1) { return; } List <string> songs = new List <string>(); foreach (DataRow row in dt.Rows) { songs.Add(Path.Combine((string)row["Path"], (string)row["File_Name"])); BCHFileIO.WriteFullFile(m3uFileName, songs, ref op); if (!op.Success) { return; } } } catch (Exception ex) { op.AddException(ex); return; } }
private void SaveMessagesToFile(ref OperationResult op) { List <string> output = new List <string>(); output.Add("Batch MP3 Edit Run " + DateTime.Now.ToShortDateString()); output.AddRange(this.CompletedMessage); output.Add("Error and Exception Messages:"); output.AddRange(this.ErrorMesssages); output.Add("Bad Files:"); output.AddRange(this.BadFiles); DateTime now = DateTime.Now; string appPath = Path.GetDirectoryName(Application.ExecutablePath); string appDriveDir = appPath; //.Substring(0,3); string infoFile = Path.Combine(appDriveDir, "BatchMp3TagEditorRun"); BCHFileIO.SaveMessagesToFile(infoFile, output, ref op); if (!op.Success) { MessageBoxIcon mbi = MessageBoxIcon.Error; string msgBxMsg = "There were errors! saving log file."; string msgCap = "ERROR!"; MessageBox.Show(msgBxMsg, msgCap, MessageBoxButtons.OK, mbi); } }
private void GetMp3songs(ref OperationResult op) { if (!Directory.Exists(dddtbGetMp3RootDir.ItemText)) { op.AddError($"\"{dddtbGetMp3RootDir.ItemText}\" does not exists."); return; } List <string> extentionFilters = new List <string> { ".mp3" }; List <string> mp3Files = BCHFileIO.GetAllFilesInDir(dddtbGetMp3RootDir.ItemText, ref extentionFilters, true, ref op); if (!op.Success) { return; } if (mp3Files == null || !mp3Files.Any()) { op.AddError($"No mp3 files."); return; } ddlbMp3s.AddFiles(mp3Files, false); }
private void AfterFileTextDrop(string fName) { OperationResult op = new OperationResult(); try { dddtbM3uPath.ItemText = Path.GetDirectoryName(fName); tbM3UFileName.Text = Path.GetFileName(fName); if (File.Exists(fName)) { var mp3s = BCHFileIO.ReadFullFile(fName, ref op); if (op.Success) { uftM3U.AddItems(mp3s, BCHControls.UCFromToEnum.From, false, true); uftM3U.AddItems(mp3s, BCHControls.UCFromToEnum.To, false, true); } else { MessageBox.Show(op.GetAllMessages("\n"), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { op.AddException(ex); MessageBox.Show(op.GetAllMessages("\n"), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnGetDir_Click(object sender, EventArgs e) { folderBrowserDialog1.ShowDialog(); if (folderBrowserDialog1.SelectedPath.Length < 0) { MessageBox.Show("You must choose a folder!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } lbMusicDirs.DataSource = BCHFileIO.GetDirPathsInPath(folderBrowserDialog1.SelectedPath); }
public void SetM3U(string fileNameAndPath, List <string> list, bool isNew, ref OperationResult op) { try { if (!isNew && !File.Exists(fileNameAndPath)) { op.AddError("The File: " + fileNameAndPath + " deos not exist!"); return; } if (Directory.Exists(Path.GetFullPath(fileNameAndPath))) { op.AddError("The Path: " + Path.GetFullPath(fileNameAndPath) + " deos not exist!"); return; } if (!isNew) { List <string> fileContents = BCHFileIO.ReadFullFile(fileNameAndPath, ref op); fileContents = ( from line in fileContents where !line.Trim().StartsWith("#") && line.Trim().Length > 1 select line ).ToList <string>(); if (!op.Success) { return; } this.M3USongList = fileContents; } else { this.M3USongList = new List <string>(); this.M3USongList.AddRange(list); } this.M3UFileNameAndPath = fileNameAndPath; this.M3UFileName = Path.GetFileName(fileNameAndPath); this.M3UPath = Path.GetFullPath(fileNameAndPath); _isSet = true; } catch (Exception ex) { op.AddException(ex); return; } }
private void CreateCopyOfDb(string dbName, ref OperationResult op) { try { if (File.Exists(dbName)) { BCHFileIO.CopyFile(dbName, true, ref op); } } catch (Exception ex) { op.AddException(ex); } }
public static void CreatePdbTable(DataTable dt, string fileName, ref OperationResult op) { string pdbTable = AddColumnRow(dt, ref op); if (op.Success) { pdbTable += AddDataRows(dt, ref op); } if (op.Success) { List <string> list = new List <string>(); list.Add(pdbTable); BCHFileIO.WriteFullFile(fileName, list, ref op); } }
private void CreateDbFiles(ref OperationResult op) { if (!MP3DBExists()) { op.AddError("You must choose an Access 2000 to 2003 version database (mdb) file!"); return; } try { MP3DBManager mdbmgr = new MP3DBManager(); mdbmgr.SetDataStore(ddtbMp3DbFile.ItemText, ref op); if (!op.Success) { return; } string dirName = dddtbTargetDir.ItemText; string delimiter = rbtnTab.Checked ? "\t" : ","; List <string> tables = new List <string> { "tbFileInfo", "tbMp3Info", "tbArtist" }; foreach (var table in tables) { string sql = $"select * from {table}"; List <string> data = GetTableData(sql, table, delimiter, ref op); if (!op.Success) { return; } string fName = Path.Combine(dirName, $"{table}.txt"); BCHFileIO.WriteFullFile(fName, data, ref op); if (!op.Success) { return; } } } catch (Exception ex) { op.AddException(ex); rtbMessages.Text = op.GetAllErrorsAndExceptions("\n"); return; } }
private void btnCrtMu3FrmPlyLst_Click(object sender, EventArgs e) { tbMessages.Text = ""; OperationResult op = new OperationResult(); try { if (this.iTuneSongs == null || iTuneSongs.iTunesSongList.Count < 1 || this.iTunesPlayLists == null || this.iTunesPlayLists.ITunesPlayLists.Count < 1) { GetiTunesLibXml(); } foreach (var pl in this.iTunesPlayLists.ITunesPlayLists) { List <string> songs = GetPlayListSongPathsList(pl); string path = this.dddtbOutputPath.ItemText; string fName = Path.Combine(path, pl.Name + ".m3u"); if (!string.IsNullOrWhiteSpace(dddMusicDirPath.ItemText)) { songs = FormatSongsMusicDir(tbLibraryMusicPath.Text, songs, dddMusicDirPath.ItemText); } BCHFileIO.WriteFullFile(fName, songs, ref op); if (!op.Success) { tbMessages.Text = op.GetAllErrorsAndExceptionsWthNl(); return; } } } catch (Exception ex) { tbMessages.Text = ex.Message; return; } tbMessages.Text = "Finished"; }
public void CreateM3U(ref OperationResult op) { if (!IsSet) { op.AddError("M3U object not set. You must call the \"SetM3U(string fileNameAndPath, " + "ref OperationResult op)\" successfully before you can create an M3U file"); return; } if (this.M3USongList.Count < 1) { op.AddError("There are no songs in the M3U list. You must call the \"SetM3USongs(List<string> list, bool" + "addOrReplace, ref OperationResult op)\" successfully before you can create an M3U file"); return; } List <string> mList = new List <string>(); //mList.Add("#EXTM3U - Created by Barry Hill's M3U Editor"); //mList.Add("#EXTINF - "); mList.AddRange(this.M3USongList); string fname = this.M3UFileNameAndPath; if (!fname.EndsWith(".m3u", StringComparison.CurrentCultureIgnoreCase)) { fname = fname + ".m3u"; } BCHFileIO.WriteFullFile(fname, mList, ref op); if (!op.Success) { return; } op.AddInformation("M3U file created successfully."); }
public static void CreateCsvTable(DataTable dt, string fileName, ref OperationResult op, string colDelim, string rowDelim) { try { string pdbTable = AddColumnRow(dt, ref op, colDelim); if (op.Success) { pdbTable += AddDataRows(dt, ref op, rowDelim); } if (op.Success) { List <string> list = new List <string>(); list.Add(pdbTable); BCHFileIO.WriteFullFile(fileName, list, ref op); } } catch (Exception ex) { op.AddException(ex); return; } }
private void btnExportSongList_Click(object sender, EventArgs e) { if (this.iTuneSongs == null || iTuneSongs.iTunesSongList.Count < 1) { GetiTunesLibXml(); } List <string> list = GetSongsList(this.iTuneSongs); OperationResult op = new OperationResult(); string path = this.dddtbOutputPath.ItemText; string fName = Path.Combine(path, "iTunesSongs.txt"); BCHFileIO.WriteFullFile(fName, list, ref op); if (!op.Success) { tbMessages.Text = op.GetAllErrorsAndExceptionsWthNl(); return; } tbMessages.Text = "Finished"; }
private void btnExportPlayLists_Click(object sender, EventArgs e) { tbMessages.Text = ""; OperationResult op = new OperationResult(); if (this.iTuneSongs == null || iTuneSongs.iTunesSongList.Count < 1 || this.iTunesPlayLists == null || this.iTunesPlayLists.ITunesPlayLists.Count < 1) { GetiTunesLibXml(); } List <Tuple <string, List <string> > > pls = GetPlayListSongsTuple(); foreach (var kv in pls) { string path = this.dddtbOutputPath.ItemText; string fName = Path.Combine(path, kv.Item1 + ".txt"); BCHFileIO.WriteFullFile(fName, kv.Item2, ref op); if (!op.Success) { tbMessages.Text = op.GetAllErrorsAndExceptionsWthNl(); return; } } if (!op.Success) { tbMessages.Text = op.GetAllErrorsAndExceptionsWthNl(); return; } tbMessages.Text = "Finished"; }