File Maker Tutorial Code Template
Understanding the Project Folder Creator Code in VB.NET
This Visual Basic .NET (VB.NET) program is designed to help beginners understand how to automate the creation of project folders for game or application development. The code is not refactored on purpose so that you can clearly see each step before making it more efficient.
This code is accompanied by a tutorial video:
Watch the tutorial here
The video will guide you through:
- Creating a new Console App in VB.NET.
- Copying and pasting this code into the project.
- Running the program and seeing how it works.
File Maker Code Template
Copy the code below
'TODO:1. Change Procedure name to your own procedure name
'TODO:2. Add Json package to the resources
'TODO:3. Create A Project Class
'TODO:4. Create A Json file for the Project Class
'TODO:5. Refactor writeFile procedure to take a string for data input
'TODO:6. move the input variable up to the global class variable access
'TODO:7. Seralize Project Class
'TODO:8. Deseralize The Project json Class
'TODO:9. Use snippets (insert comment) to add comments to procedures and functions
'TODO:10.Refactor your code to create subfolders in a separate procedure
'TODO:11.Remove reference comments
Module Module1
'READ: 'More information on file reading and writing in the coursebook: pg 68: FileRead
'https://drive.google.com/file/d/1qwb9Sq3bf9sWPdAUeiFX_xM1Knb4Ikpp/view
Dim ProjectName As String
Dim FullDirectory As String
Sub Main()
Dim input As String = 0
While input <> "exit"
Console.WriteLine("please enter product name.")
ProjectName = Console.ReadLine
Console.WriteLine("Please enter a command Exit | create")
input = Console.ReadLine.ToString()
If input = "create" Then
MakeP2PProjectFolders()
End If
End While
End Sub
Private Sub MakeP2PProjectFolders()
'TODO: Add Json database
'TODO: Change MakeP2PProjectFolders to MakeProjectFolders
Dim newFolderPath As String = My.Computer.FileSystem.SpecialDirectories.Desktop
If ProjectName = "" Then
ProjectName = " Not Set\"
End If
' My.Computer.FileSystem.CreateDirectory(newFolderPath + ProjectName)
CreateProjectFolder(newFolderPath, ProjectName)
newFolderPath += "\" + ProjectName
FullDirectory = newFolderPath
CreateProjectFolder(newFolderPath, "\Art")
WriteFile("ReadMe.txt", newFolderPath)
WriteFile("Art\Art_ReadMe.txt", newFolderPath)
CreateProjectFolder($"{newFolderPath}\Art", "Animations")
CreateProjectFolder($"{newFolderPath}\Art\Animations", "AnimationClips")
CreateProjectFolder($"{newFolderPath}\Art\Animations\AnimationClips", "Player")
CreateProjectFolder($"{newFolderPath}\Art\Animations\AnimationClips", "Enemies")
CreateProjectFolder($"{newFolderPath}\Art\Animations\AnimationClips", "Interactables")
CreateProjectFolder($"{newFolderPath}\Art\Animations\AnimationClips", "UI")
CreateProjectFolder($"{newFolderPath}\Art\Animations\AnimationClips\UI", "Menu")
CreateProjectFolder($"{newFolderPath}\Art\Animations\AnimationClips\UI", "HUD")
CreateProjectFolder($"{newFolderPath}\Art\Animations\AnimationClips\UI", "Dialogue")
CreateProjectFolder($"{newFolderPath}\Art\Animations\AnimationClips", "VFX")
CreateProjectFolder($"{newFolderPath}\Art\Animations\AnimationClips\VFX", "Player")
CreateProjectFolder($"{newFolderPath}\Art\Animations\AnimationClips\VFX", "Enemies")
CreateProjectFolder($"{newFolderPath}\Art\Animations", "Animators")
CreateProjectFolder($"{newFolderPath}\Art\Animations\Animators", "Player")
CreateProjectFolder($"{newFolderPath}\Art\Animations\Animators", "Enemies")
CreateProjectFolder($"{newFolderPath}\Art\Animations\Animators", "Interactables")
CreateProjectFolder($"{newFolderPath}\Art\Animations\Animators", "UI")
CreateProjectFolder($"{newFolderPath}\Art\Animations\Animators\UI", "Menu")
CreateProjectFolder($"{newFolderPath}\Art\Animations\Animators\UI", "HUD")
CreateProjectFolder($"{newFolderPath}\Art\Animations\Animators\UI", "Dialogue")
CreateProjectFolder($"{newFolderPath}\Art\Animations\Animators", "VFX")
CreateProjectFolder($"{newFolderPath}\Art\Animations\Animators\VFX", "Player")
CreateProjectFolder($"{newFolderPath}\Art\Animations\Animators\VFX", "Enemies")
CreateProjectFolder($"{newFolderPath}\Art\Animations", "Timeline")
CreateProjectFolder($"{newFolderPath}\Art", "Materials")
CreateProjectFolder($"{newFolderPath}\Art\Materials", "Player")
CreateProjectFolder($"{newFolderPath}\Art\Materials", "Enemies")
CreateProjectFolder($"{newFolderPath}\Art\Materials", "Environment")
CreateProjectFolder($"{newFolderPath}\Art\Materials", "Interactables")
CreateProjectFolder($"{newFolderPath}\Art\Materials", "PhysicsMaterials")
CreateProjectFolder($"{newFolderPath}\Art\Materials", "UI")
CreateProjectFolder($"{newFolderPath}\Art\Materials\UI", "Menu")
CreateProjectFolder($"{newFolderPath}\Art\Materials\UI", "HUD")
CreateProjectFolder($"{newFolderPath}\Art\Materials\UI", "Dialogue")
CreateProjectFolder($"{newFolderPath}\Art\Materials", "VFX")
CreateProjectFolder($"{newFolderPath}\Art\Materials\VFX", "Player")
CreateProjectFolder($"{newFolderPath}\Art\Materials\VFX", "Enemies")
CreateProjectFolder($"{newFolderPath}\Art\Materials\VFX", "Environment")
CreateProjectFolder($"{newFolderPath}\Art\Materials\VFX", "Interactables")
CreateProjectFolder($"{newFolderPath}\Art", "Sprites")
CreateProjectFolder($"{newFolderPath}\Art\Sprites", "AnimatedSprites")
CreateProjectFolder($"{newFolderPath}\Art\Sprites", "Environment")
CreateProjectFolder($"{newFolderPath}\Art\Sprites", "Interactables")
CreateProjectFolder($"{newFolderPath}\Art\Sprites", "Icons")
CreateProjectFolder($"{newFolderPath}\Art\Sprites", "UI")
CreateProjectFolder($"{newFolderPath}\Art\Sprites\UI", "HUD")
CreateProjectFolder($"{newFolderPath}\Art\Sprites\UI", "Menu")
CreateProjectFolder($"{newFolderPath}\Art\Sprites", "Utilities")
CreateProjectFolder($"{newFolderPath}\Art\Sprites", "VFX")
CreateProjectFolder($"{newFolderPath}\Art\Sprites\VFX", "Player")
CreateProjectFolder($"{newFolderPath}\Art\Sprites\VFX", "Enemies")
CreateProjectFolder($"{newFolderPath}\Art\Sprites\VFX", "Environment")
CreateProjectFolder($"{newFolderPath}\Art\Sprites\VFX", "Interactables")
CreateProjectFolder($"{newFolderPath}\Art\Sprites\VFX", "Utilities")
CreateProjectFolder($"{newFolderPath}\Art", "TileMapPalettes")
CreateProjectFolder($"{newFolderPath}\Art\TileMapPalettes", "TileSets")
CreateProjectFolder(newFolderPath, "\Audio")
CreateProjectFolder($"{newFolderPath}\Audio", "Player")
CreateProjectFolder($"{newFolderPath}\Audio\Player", "Attacks")
CreateProjectFolder($"{newFolderPath}\Audio\Player\Attacks", "Melee")
CreateProjectFolder($"{newFolderPath}\Audio\Player\Attacks", "Ranged")
CreateProjectFolder($"{newFolderPath}\Audio\Player", "Emotes")
CreateProjectFolder($"{newFolderPath}\Audio\Player", "Locomotion")
CreateProjectFolder($"{newFolderPath}\Audio\Player", "Speech")
CreateProjectFolder($"{newFolderPath}\Audio", "Enemies")
CreateProjectFolder($"{newFolderPath}\Audio", "Environment")
CreateProjectFolder($"{newFolderPath}\Audio", "Interactables")
CreateProjectFolder($"{newFolderPath}\Audio", "FX")
CreateProjectFolder($"{newFolderPath}\Audio", "Mixers")
CreateProjectFolder($"{newFolderPath}\Audio", "Music")
CreateProjectFolder($"{newFolderPath}\Audio", "UI")
CreateProjectFolder(newFolderPath, "\Documentation")
CreateProjectFolder($"{newFolderPath}\Documentation", "Sources")
CreateProjectFolder($"{newFolderPath}\Documentation\Sources", "Components")
CreateProjectFolder($"{newFolderPath}\Documentation\Sources", "Guides")
CreateProjectFolder(newFolderPath, "\Prefabs")
CreateProjectFolder($"{newFolderPath}\Prefabs", "Audio")
CreateProjectFolder($"{newFolderPath}\Prefabs", "Player")
CreateProjectFolder($"{newFolderPath}\Prefabs", "Enemies")
CreateProjectFolder($"{newFolderPath}\Prefabs", "Environment")
CreateProjectFolder($"{newFolderPath}\Prefabs", "Interactables")
CreateProjectFolder($"{newFolderPath}\Prefabs", "SceneControl")
CreateProjectFolder($"{newFolderPath}\Prefabs", "UIPrefabs")
CreateProjectFolder($"{newFolderPath}\Prefabs", "VFX")
CreateProjectFolder($"{newFolderPath}\Prefabs\VFX", "Player")
CreateProjectFolder($"{newFolderPath}\Prefabs\VFX", "Enemies")
CreateProjectFolder($"{newFolderPath}\Prefabs\VFX", "Environment")
CreateProjectFolder($"{newFolderPath}\Prefabs\VFX", "Interactables")
CreateProjectFolder(newFolderPath, "\Scenes")
CreateProjectFolder($"{newFolderPath}\Scenes", "UI")
CreateProjectFolder($"{newFolderPath}\Scenes", "Utilities")
CreateProjectFolder($"{newFolderPath}\Scenes", "Zones")
CreateProjectFolder(newFolderPath, "\Macros")
CreateProjectFolder(newFolderPath, "\Script")
CreateProjectFolder($"{newFolderPath}\Script", "UI")
CreateProjectFolder($"{newFolderPath}\Script", "Utility")
CreateProjectFolder($"{newFolderPath}\Script", "AI")
CreateProjectFolder($"{newFolderPath}\Script", "Audio")
CreateProjectFolder($"{newFolderPath}\Script", "Character")
CreateProjectFolder($"{newFolderPath}\Script\Character", "Editor")
CreateProjectFolder($"{newFolderPath}\Script\Character", "MonoBehaviours")
CreateProjectFolder($"{newFolderPath}\Script\Character", "StateMachineBehaviours")
CreateProjectFolder($"{newFolderPath}\Script\Character\StateMachineBehaviours", "Enemies")
CreateProjectFolder($"{newFolderPath}\Script\Character\StateMachineBehaviours", "Player")
CreateProjectFolder($"{newFolderPath}\Script", "Core")
CreateProjectFolder($"{newFolderPath}\Script", "Editor")
CreateProjectFolder($"{newFolderPath}\Script\Editor", "PackageManagerAssembly")
CreateProjectFolder($"{newFolderPath}\Script\Editor\PackageManagerAssembly", "PackageManagerAssembly")
CreateProjectFolder($"{newFolderPath}\Script", "Effect")
CreateProjectFolder($"{newFolderPath}\Script", "Localization")
CreateProjectFolder($"{newFolderPath}\Script\Localization", "Editor")
CreateProjectFolder($"{newFolderPath}\Script", "Objects")
CreateProjectFolder($"{newFolderPath}\Script\Objects", "Editor")
CreateProjectFolder($"{newFolderPath}\Script", "SceneManagement")
CreateProjectFolder($"{newFolderPath}\Script\SceneManagement", "Editor")
CreateProjectFolder($"{newFolderPath}\Script", "TimeLine")
CreateProjectFolder($"{newFolderPath}\Script\TimeLine", "Editor")
CreateProjectFolder($"{newFolderPath}\Script\TimeLine\ScrollingText", "Editor")
CreateProjectFolder(newFolderPath, "\Models")
CreateProjectFolder(newFolderPath, "\Graphs")
CreateProjectFolder($"{newFolderPath}\Graphs", "Macro")
CreateProjectFolder($"{newFolderPath}\Graphs", "Flow")
CreateProjectFolder($"{newFolderPath}\Graphs", "State")
CreateProjectFolder(newFolderPath, "\Sounds")
CreateProjectFolder(newFolderPath, "\Utilities")
Console.WriteLine("Project created in: " + FullDirectory)
End Sub
Private Sub WriteFile(fileName As String, location As String)
'Ref:https://docs.microsoft.com/en-us/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-write-text-to-files-with-a-streamwriter
If fileName <> "" Then
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(location + "\" + fileName + ".txt", True)
file.WriteLine("This is a readme file for the team")
file.Close()
End If
End Sub
Sub CreateProjectFolder(newFolderPath As String, ProjectName As String)
My.Computer.FileSystem.CreateDirectory(newFolderPath + ProjectName)
End Sub
End Module
How the Code Works
The program prompts the user to enter a project name and a command (exit
or create
). If the user chooses create, the program generates a structured set of folders on the desktop.
It follows a step-by-step process:
- Asks the user for a project name.
- Creates folders based on a pre-defined structure.
- Generates “ReadMe.txt” files inside certain folders.
- Displays the location of the created project.
This ensures that all necessary folders for art, animations, scripts, audio, and prefabs are automatically created.
Step-by-Step Explanation
1️⃣ Main Program Execution (Main
Method)
This is where everything starts:
Sub Main()
Dim input As String = 0
While input <> "exit"
Console.WriteLine("Please enter project name.")
ProjectName = Console.ReadLine()
Console.WriteLine("Please enter a command: Exit | create")
input = Console.ReadLine().ToString()
If input = "create" Then
MakeP2PProjectFolders()
End If
End While
End Sub
💡 What this does:
- Asks the user for a project name.
- Asks for a command:
"exit"
(to quit) or"create"
(to generate folders). - Calls the function
MakeP2PProjectFolders()
when"create"
is chosen.
2️⃣ Creating the Project Folders (MakeP2PProjectFolders
)
Private Sub MakeP2PProjectFolders()
Dim newFolderPath As String = My.Computer.FileSystem.SpecialDirectories.Desktop
If ProjectName = "" Then
ProjectName = " Not Set\"
End If
' Creates the main project folder
CreateProjectFolder(newFolderPath, ProjectName)
newFolderPath += "\" + ProjectName
FullDirectory = newFolderPath
' Creates subfolders inside the project
CreateProjectFolder(newFolderPath, "\Art")
WriteFile("ReadMe.txt", newFolderPath)
CreateProjectFolder($"{newFolderPath}\Audio", "Player")
CreateProjectFolder($"{newFolderPath}\Scripts", "GameLogic")
Console.WriteLine("Project created in: " + FullDirectory)
End Sub
💡 What this does:
- Gets the Desktop path to create the project folders there.
- Checks if the project name is empty and assigns a default name.
- Calls
CreateProjectFolder()
multiple times to generate directories.
3️⃣ Writing a “ReadMe.txt” File (WriteFile
Method)
Private Sub WriteFile(fileName As String, location As String)
If fileName <> "" Then
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(location + "\" + fileName, True)
file.WriteLine("This is a readme file for the team")
file.Close()
End If
End Sub
💡 What this does:
- Creates a ReadMe.txt file inside the project folder.
- Writes basic information to the file.
4️⃣ Folder Creation Function (CreateProjectFolder
)
Sub CreateProjectFolder(newFolderPath As String, ProjectName As String)
My.Computer.FileSystem.CreateDirectory(newFolderPath + ProjectName)
End Sub
💡 What this does:
- Uses VB.NET file system functions to create directories.
- Takes in the base path and the folder name to generate subfolders.
Why is the Code Not Refactored Yet?
This version of the code is written in a way that makes it easy for beginners to follow. Each folder is created manually so you can see every step clearly.
Later, after understanding:
✅ How to create folders
✅ How to write text files
✅ How to handle user input
We can refactor the code to make it shorter, more efficient, and modular.
What You Will Learn from This Code
- Basic VB.NET programming
- How to handle user input in a console application
- How to create directories and files programmatically
- How to structure project folders for game/app development
Next Steps
- Once you understand this, you can:
- Modify folder names to suit your needs.
- Enhance the program by adding more structure.
- Use JSON files to save project settings.
- Improve efficiency by creating folders dynamically.
- Start by following the tutorial video: Watch here