private void btnSelectGitHubFolder_Click(object sender, EventArgs e) { if (folderBrowser.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (folderBrowser.SelectedPath != string.Empty) { txtGitHubFolder.Text = folderBrowser.SelectedPath; JsonFile file = new JsonFile(); file.Directory = Application.StartupPath + "\\"; file.FileName = "gh"; JsonFileResponse r = file.Write(txtGitHubFolder.Text.Trim()); } } }
private void btnBuscar_Click(object sender, EventArgs e) { folderBrowser.SelectedPath = localLastPath; //folderBrowser.RootFolder = Environment.SpecialFolder.MyDocuments; if (folderBrowser.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (folderBrowser.SelectedPath != string.Empty) { txtDirectory.Text = folderBrowser.SelectedPath; JsonFile file = new JsonFile(); file.Directory = Application.StartupPath + "\\"; file.FileName = "local"; JsonFileResponse r = file.Write(txtDirectory.Text.Trim()); } } }
private void btnSave_Click(object sender, EventArgs e) { if (MessageBox.Show("¿Estás seguro?", "Guardar Canciones", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { foreach (Artist artist in artists) { admin.Library.artist_list.Add(artist); } foreach (Album album in albums) { admin.Library.album_list.Add(album); } foreach (Song song in songs) { if (!admin.Library.song_list.Contains(song)) { admin.Library.song_list.Add(song); } } if (!Directory.Exists(txtGitHubFolder.Text)) { folderBrowser.ShowDialog(); { if (folderBrowser.SelectedPath != string.Empty) { txtGitHubFolder.Text = folderBrowser.SelectedPath; JsonFile file = new JsonFile(); file.Directory = Application.StartupPath + "\\"; file.FileName = "gh"; JsonFileResponse r = file.Write(txtGitHubFolder.Text.Trim()); } } } int i = 0; if (chkCopiar.Checked) { foreach (Song s in songs) { Artist a = Artist.get(admin.Library.artist_list, s.artist_id); Album al = Album.get(admin.Library.album_list, s.album_id); if (!Directory.Exists(txtGitHubFolder.Text + "\\" + Tools.ConvertToGitHubFolder(a.name))) { Directory.CreateDirectory(txtGitHubFolder.Text + "\\" + Tools.ConvertToGitHubFolder(a.name)); } if (!Directory.Exists(txtGitHubFolder.Text + "\\" + Tools.ConvertToGitHubFolder(a.name) + "\\" + Tools.ConvertToGitHubFolder(al.name))) { Directory.CreateDirectory(txtGitHubFolder.Text + "\\" + Tools.ConvertToGitHubFolder(a.name) + "\\" + Tools.ConvertToGitHubFolder(al.name)); } //opus if (!Directory.Exists(txtGitHubFolder.Text + "\\opus\\" + Tools.ConvertToGitHubFolder(a.name) + "\\" + Tools.ConvertToGitHubFolder(al.name))) { Directory.CreateDirectory(txtGitHubFolder.Text + "\\opus\\" + Tools.ConvertToGitHubFolder(a.name) + "\\" + Tools.ConvertToGitHubFolder(al.name)); } //if (!System.IO.File.Exists(txtGitHubFolder.Text + "\\" + Tools.ConvertToGitHubFolder(a.name) + "\\" + Tools.ConvertToGitHubFolder(al.name) + "\\Cover.jpg")) //{ // if (System.IO.File.Exists(Covers[i])) // { // System.IO.File.Copy(Covers[i], txtGitHubFolder.Text + "\\" + Tools.ConvertToGitHubFolder(a.name) + "\\" + Tools.ConvertToGitHubFolder(al.name) + "\\Cover.jpg"); // } //} //if (!System.IO.File.Exists(txtGitHubFolder.Text + "\\" + Tools.ConvertToGitHubFolder(a.name) + "\\" + Tools.ConvertToGitHubFolder(al.name) + "\\CoverSmall.jpg")) //{ // if (System.IO.File.Exists(CoversSmall[i])) // { // System.IO.File.Copy(CoversSmall[i], txtGitHubFolder.Text + "\\" + Tools.ConvertToGitHubFolder(a.name) + "\\" + Tools.ConvertToGitHubFolder(al.name) + "\\CoverSmall.jpg"); // } //} string tn = ""; if (s.Track > 0) { if (s.Track < 10) { tn = "0" + s.Track; } else { tn = s.Track.ToString(); } } System.IO.File.Copy(Files[i], txtGitHubFolder.Text + "\\" + Tools.ConvertToGitHubFolder(a.name) + "\\" + Tools.ConvertToGitHubFolder(al.name) + "\\" + Song.getFileFormat(s) + Path.GetExtension(Files[i])); i++; } } this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { } } }
private void btnSave_Click(object sender, EventArgs e) { if (MessageBox.Show("¿Estás seguro?", "Guardar Canciones", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { foreach (Artist artist in artists) { admin.Library.artist_list.Add(artist); } foreach (Album album in albums) { admin.Library.album_list.Add(album); } foreach (Song song in songs) { if (!admin.Library.song_list.Contains(song)) { admin.Library.song_list.Add(song); } } if (!Directory.Exists(txtGitHubFolder.Text)) { folderBrowser.ShowDialog(); { if (folderBrowser.SelectedPath != string.Empty) { txtGitHubFolder.Text = folderBrowser.SelectedPath; JsonFile file = new JsonFile(); file.Directory = Application.StartupPath + "\\"; file.FileName = "gh"; JsonFileResponse r = file.Write(txtGitHubFolder.Text.Trim()); } } } int i = 0; foreach (Song s in songs) { Artist a = Artist.get(admin.Library.artist_list, s.artist_id); Album al = Album.get(admin.Library.album_list, s.album_id); if (!Directory.Exists(txtGitHubFolder.Text + "\\" + a.url_name)) { Directory.CreateDirectory(txtGitHubFolder.Text + "\\" + a.url_name); } if (!Directory.Exists(txtGitHubFolder.Text + "\\" + a.url_name + "\\" + al.url_name)) { Directory.CreateDirectory(txtGitHubFolder.Text + "\\" + a.url_name + "\\" + al.url_name); } if (!System.IO.File.Exists(txtGitHubFolder.Text + "\\" + a.url_name + "\\" + al.url_name + "\\Cover.jpg")) { if (System.IO.File.Exists(Covers[i])) { System.IO.File.Copy(Covers[i], txtGitHubFolder.Text + "\\" + a.url_name + "\\" + al.url_name + "\\Cover.jpg"); } } System.IO.File.Copy(Files[i], txtGitHubFolder.Text + "\\" + a.url_name + "\\" + al.url_name + "\\" + s.file_name); i++; } this.DialogResult = DialogResult.OK; } catch (Exception ex) { } finally { songs.Clear(); albums.Clear(); artists.Clear(); } } }