Noki Posted March 16, 2014 Share Posted March 16, 2014 Hello, I am looking for someone to guide me in C#. I am not looking for someone to walk me through, or someone to teach me. I am purely looking for someone that is able to serve as a guide. I would need occasional help (debugging code, explanations etc) that cold PDF tutorials cannot deliver. I am new to C#. If you are interested, I am able to pay you for your help on a commission basis. Thank you. Link to comment
xXMADEXx Posted March 20, 2014 Share Posted March 20, 2014 Well, recently I've also been learning C#. I made a pretty cool program that sorts your music, here is the source code if you want to learn off of it using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Collections; namespace Music_Sorter { class Program { public static void startApplication(Boolean doConfigs) { String user = Environment.UserName; String directory = "C:\\Users\\" + user + "\\Music"; if (doConfigs) { Console.Title = "Music Organizer - " + user; Console.WriteLine("Please be sure all of your .mp3 files are in your music directory... When you're ready, press any key. (Music directory: { 0 })", directory); Console.ReadKey(); } Console.WriteLine("\nGathering music..."); string[] ListFiles = Directory.GetFiles(directory, "*.mp3"); if (ListFiles.Length == 0) { Console.WriteLine("No music files found. Press any key to continue."); Console.ReadKey(); Environment.Exit(0); return; } Console.WriteLine("The MP3 files that were found are ("+ListFiles.Length+" songs): "); for (int i = 0; i < ListFiles.Length; i++) { Console.WriteLine(ListFiles[i].ToString()); } Console.WriteLine("\n\nPlease type Y to continue, or R to refresh the list. Any other key will kill the application."); String text = Console.ReadLine().ToLower(); if (text != "y" && text != "r") { Console.WriteLine("Killing application..."); Environment.Exit(0); return; } if (text == "r") { Console.WriteLine("\n\n\n\nRefreshing list..."); Program.startApplication(false); return; } Console.WriteLine("Continuing with orgaization...."); int unknownSong = 0; ArrayList unknownSongs = new ArrayList(); unknownSongs = new ArrayList(); for (int i = 0; i < ListFiles.Length; i++) { TagLib.File file = TagLib.File.Create(ListFiles[i]); //String genre = file.Tag.genre; string[] artists = file.Tag.Artists; String Album = file.Tag.Album; String artist = ""; String title = file.Tag.Title; Boolean isUnknown = false; for (int i2 = 0; i2 < artists.Length; i2++) { if (i2 == 0) { artist = artists[i2]; } else { artist = artist + ", " + artists[i2]; } } if (title == null || title.Replace(" ", "") == "") { title = "Unknown (" + unknownSong + ")"; unknownSong++; isUnknown = true; } if (artist == null || artist.Replace(" ", "") == "") { artist = "Unknown"; isUnknown = true; } if (Album == null || Album.Replace(" ", "") == "") { Album = "Unknown"; isUnknown = true; } foreach (char c in Path.GetInvalidFileNameChars()) { Album = Album.Replace(c, '_'); title = title.Replace(c, '_'); artist = artist.Replace(c, '_'); } String path = directory + "\\Organized Music\\" + artist + "\\" + Album; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = path + "\\" + title; if (File.Exists(path + ".mp3")) { int whileID = 0; String tempPath = "Unknown" + path; while (File.Exists ( tempPath + ".mp3" ) ) { //if (whileID == 0) //{ tempPath = path + "(" + whileID + ")"; //} whileID++; } path = tempPath; } Console.WriteLine("\n\nMoving: " + ListFiles[i] + "\nTo: " + path + ".mp3"); File.Move(ListFiles[i], path + ".mp3"); if (isUnknown) { unknownSongs.Add(path+".mp3"); } } Console.WriteLine ( "\n\n\n" ); if (unknownSongs.Count > 0) { Console.WriteLine(unknownSongs.Count + " songs failed to be identified. List: \n"); for (int i = 0; i < unknownSongs.Count; i++) { Console.WriteLine(i + ". " + unknownSongs[i]); } } else { Console.WriteLine("All songs have been successfully organized!"); } Console.ReadKey(); } static void Main() { startApplication(true); } } } You have to import this library though. Link to comment
Noki Posted March 20, 2014 Author Share Posted March 20, 2014 I have tried studying code, but I just can't get my head around C#. The one language I want to understand is the one I can't lol. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now