Could not find a part of the path

Please tell me what is wrong with this!

if (!Directory.Exists(@"Assets\Levels\" + title + @"\data"))
{
    Directory.CreateDirectory(@"Assets\Levels\" + title + @"\data");
 }

There’s nothing wrong with this, why is Unity such a buggy mess!

If you want help debugging a problem, you should generally say:

  • What you are trying to accomplish
  • How you tried to accomplish it
  • What actually happened (and how it differed from your expectation, if that’s not obvious)

Your source code possibly covers #2, but you’re missing #1 and #3. Why are you messing with directories inside your assets folder from code, and what is your program actually doing when you run it?

Unless this code is intended to run while in editor mode, you should note that the “assets” directory doesn’t normally exist in your final game build.

1 Like