How to arrange the source in diffrent folders

Hi,

I am trying arrange my source code files in different folders but I am getting errors while I am compiling them.

1>D:/Unreal Engine - 4/../ue4/New folder/MyProject/Source/MyProject/Projectiles/TripleProjectile.h(5): fatal error C1083: Cannot open include file: 'BaseProjectile.h': No such file or directory

.h file

#include "BaseProjectile.h"

Try this:

#include "MyProject/Projectiles/BaseProjectile.h"

The right way to organize your folder structure involves declaring it by hand in (ProjectName).build.cs file, just look how I did this:

using UnrealBuildTool;

public class MyProject : ModuleRules
{
	public MyProject(TargetInfo Target)
	{
		//Folders to work with:
        PrivateIncludePaths.AddRange(new string[] {
            "MyProject/Projectiles",
            "MyProject"
        });

        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
	}
}

This way you could just #include “BaseProjectiles.h” and the compiler will automatically search inside all your paths.

This is going to be a lot better compared to the other method.

The folders are not present in the solution explorer in VS.

And when I try to open the files present in the folder, I get and error

Could not find file ‘old path

You have to remember that Visual Studio does not track the folder structure. What you see in Solution explorer is called a “filter”, a .vcxproj.filters file, which contains references to all files in your project. It also defines internal project organization (solution folders), which is independent of the real location of the files. The filter is updated only if you edit the project from within Visual Studio, for example, using commands like Add files to project. Any external modifications (deletes, renames etc) are unbeknownst to the filter and break its references, leaving you with a project which includes non-existent files.
So, now you have a broken filter and to options: either to fix it, or to recreate it. I would choose the latter, because it is less confusing and more reliable. Check that you have a working uproject file. Collect your source files in real folders the way you like (maybe even make a backup of “Source” and “Intermediate/Project files”, because source files are created by VS in the latter by default), then delete Intermediate folder and solution files. Right-click on uproject file, and select “Generate VS project files”. Open the new solution and add start adding your files. Again, remember that you do not have to create a real folder when adding files in a solution folder. Once it’s done, you should be able to build much like you did all the time.
If you don’t want to deal with the hassle of recreating project files, you might try manually removing missing files from the project and then re-adding them.
As for the initial question, (ProjectName).build.cs is usually inside Source/(ProjectName)/ folder both on the disk and in the project.

I added new code to the project and in my solution explorer a new folder called projectile was present and all the files were inside it and I could open it. It got auto arranged some how.