Hi!
Before I say anything, I would like to warn you that pretty much everything related to both this project and this post is made by an almost complete beginner.
I don't really have any experience with C# or with using GitHub, so I apologize if I made a few mistakes trying to work on this little project.
Thank you for understanding.
Now, let's begin with the actual post.
A few months ago I decided I wanted to learn a programming language. Again.
If you've been following me for a while then you probably know that I tried that in the past quite a few times. I started with web development, then I tried learning Python, and then I went back to web development, just to stop trying after a few months. Apparently I don't really like JavaScript and JavaScript doesn't really like me.
But, because I'm the type of person who just doesn't lean to stop, I decided to try once again, this time with something a little different - C#.
I chose C# for a few reasons.
First, I would love to be able to create a game at some point in the future, and since the game engine I would like to use is Unity, which uses C#, it seemed like a good idea to learn that specific language.
Besides that, I thought it would be smart to learn a language that I could use to code small pieces of code that could help me do things on my computer. That could be quite motivating for me, and it would be a quick way to see results.
With those two reasons in mind, I started learning the language, by first watching a 4 hour beginner course on YouTube in order to learn the basics. If you're interested, you can find it here .
It's quite basic, but it's enough to get you started.
Once I was done with it, I started working on several really simple projects in order to better understand the language. The first two were a "number guessing game" and a "paper-rock-scissors game". Not that complicated.
The third one was a "hangman" game, which took me a few weeks to complete. There were 3 things that I found really difficult to do while trying to work on it:
Taking a word, separating it into letters and then replacing those letters with "_" was a pain in the a*s to do in C#, because I had no idea how to do it, because I didn't know I had to use the "char" variable type and a stringbuilder.
Once I learned that, I had to learn a little bit of Regex, and try to use it in a "while" loop to make sure that if the user guesses the letter "p" from the word "apple", both letters would be found and "guessed", not only the first one.
I'm not gonna go into a lot of details as to how I actually created the hangman game, because it would take some time. If you are interested, I could create another separate post just for that. Let me know in the comments.
Anyway, once I was done, I decided to work on something a little more complicated, and more useful. I started working on a really simple "navigation system", but I failed quite quickly. I wasn't experienced enough to be able to create something like that.
So, I decided to make a "folder creator" program, that would help me create multiple folders, if I needed to do that, without needing to do it manually and without having to download a special software that does it for me. Or use PowerShell.
Before I even start talking about the code, you can find everything on GitHub and take a look at it yourself. Here's the link: https://github.com/raikuhen/folder-creator
I hope it works. If not, let me know. I don't yet understand how GitHub works.
Also, I'm not gonna go into "extreme" detail when it comes to the code, at least not here. That would be really tedious for people who have absolutely no idea how to code. If you really want me to do that, let me know, and I'll do it.
Leaving that aside, the code is actually quite simple, and the logic behind it is really simple as well.
Oh, I also need to mention that since I'm still at the beginning, I don't really know how to create an interface, except making simple things with WPF. So, the program only runs in the console.
Anyway, here's how the program works, which is the same explanation given in the "README" file on GitHub:
It asks the user for a path where the folders will be created. The path would look something like this: C:\Users\userName\Desktop
It asks the user for the type of "naming scheme" he/she would like to use. For example, if the "naming scheme" would be "testing", and the user wants to create 3 folders, the folders will be named "testing" , "testing1" and "testing2".
It asks the user how many folders he/she wants to create. If the number of folders is higher than 50, the user will be asked if he/she really wants to create so many folders. This is added to prevent the user from accidentally creating too many folders.
Once the folders are created, the user is asked whether he/she wants to open a Windows Explorer window to where the folders were created. In this case, if the folders were created on the Desktop, then a window containing all the files on the Desktop is opened.
Finally, the user is asked whether he/she wants to keep using the program. This is done in case you want to create multiple folders within folders.
It's fairly basic.
Everything runs using a "while" loop and an outside variable called "numberOfRuns" that keeps the loop going until either a "break" statement is given, or the value of the variable changes from 0 to 1.
Once the loop starts, the code in it is quite simple, as you'll see.
First, I use Console.Write(); to display a piece of text that asks the user for a path where the folders will be created. Then I store the input in a variable called "directoriesPath". After that, I created another variable, this time a boolean, called "directoryExists" that will be used to check whether the path exists or not.
Then, I begin the code with a simple "if-else" statement, checking if the path given by the user exists or not. If yes, then the program continues. If not, then the user is asked to retype the desired path.
Once the user types in an existing path, he is asked to provide a "name scheme" for the folders.
Here, the user has 3 options.
Give a random name that he wishes.
Give the name "months" to use the "Months" template
Give the name "days" to use the "Days" template.
Before the While loop, you can see two lists called "monthsTemplates" and "daysTemplate". The first one contains 12 items, which are obviously the name of all the months, and the second one contains 7 items, the names of all the days in a week.
Those templates are created to make the naming of the folders a lot easier for specific needs.
In the case of the first template, if the user types in "months", he is asked if he wants to use the "months" template. If the answer is "yes" (in this case "y", because all the answers can be answered by typing in "y" for "yes" and "n" for "no"), then he is prompted with another question, asking if he wants to also add a year at the end of each name.
If yes, the user has to also type in a year. If not, then 12 folders will be created.
This way, if you want to create 12 folders with the name of each month and a specific year, you can quickly do it.
If the user wants to use the "Days" template, then all he has to do is type in "days"
Each operation is handled by a "for" loop that goes through the lists I mentioned above, using all the items as names for the folders that will be created.
Finally, if the user doesn't want to use any of the templates, he can simply type in whatever name he wants, and then he will be asked to provide a number of folders to be created.
Before the process starts however, there is another small piece of code that checks whether the number of folders that are gonna be created is higher than 50.
This is done to prevent "accidents". Let's say you want to create 13 folders but by accident you add another "3", resulting in 133 folders created.
So, if the amount of folders you want to create is higher than 50, then you are asked if you're sure.
If yes, the folders are created.
If not, then the program starts once again.
Once the folders are created, you will be prompted with two additional questions.
First, the program asks you if you want to open a window to where the folders were created. This is done in case you want to quickly go to the place where the folders were created, using the Windows Explorer, without having to manually do it. No matter the answer, the next question will be asked.
Second, the program asks you if you want to restart everything or not. If the answer is "no", then the program stops. If the answer is yes, then the entire process restarts, and you are asked for a path where the next folders will be created.
This project helped me learn a lot about coding in C# and creating some kind of a functional and somewhat useful program.
There were a few important lessons I learned from this, and I'll quickly talk about them here.
First, I obviously learned how to navigate through my computer with C#, which I had no idea how to do before starting to work on this project. I learned how to do this mainly from THIS video.
Second, I learned how to better use loops and user input. There's quite a difference between what you learn by creating games like 'hangman" or "paper-rock-scissors", and actually working on something somewhat useful and more complex. You learn a lot from working on the second type of project.
Third, I learned how important it is to structure my code in a good and clean way, because it's so easy to just get lost in it and forget where certain things are. Using comments is also so damn important, because it's so easy to forget what the code you wrote yesterday does.
Finally, I learned the importance of a really good plan before actually coding. This I mainly learned from the book "C# Programming Yellow Book". Having a well thought plan about what and how to code is extremely useful.
The word "conclusion" isn't exactly the right word for the end of this type of article, but at this hour I can't really come up with a better word, so you'll have to excuse me.
It took me a few days, maybe a week to complete this project, while also working on a bunch of other things. It wasn't too complicated, but it definitely helped me learn a lot.
It also was a lot of fun to create.
But the most important part, is that I felt really good about creating something that could actually be used by someone to do something useful. It motivated me to learn more and to develop other things.
As of right now, I'm gonna resume learning before starting to work on another project, so you won't see another one of these posts very soon.
I have problems with properly understanding the "object oriented programming" part in C#, and I need to work on understanding how to use objects and classes in my code.
I also don't know how to create interfaces, and from what I read, working only with the Console in C# is gonna be limiting, depending on what I want to code. I tried learning a bit of WPF, and I understood the basics, but I think I'm gonna have to use WinForms first, and get used to that, before trying to use something more complex.
There's a lot I don't know, and a lot I don't even know I don't know. There's gonna be a lot of learning to be done, but I feel like programming can be fun, besides being extremely frustrating.
Anyway, this is pretty much all I'm gonna write here. It's already too late and I'm tired. If you take a look at the code I uploaded on GitHub, feel free to leave feedback, either here or there.
Also, if you have any recommendations for what I should learn, and how, or what I should try working on next, I would appreciate all the help.
Thank you for your time and have a great day!
Oh yeah, final note - sorry for any grammatical mistakes that are present in the article. It's really late, I'm really tired, and editing a post like this one is tedious, so I apologize if I made a bunch of mistakes here and there.