File.Exists problem in Editor and Build

Hey, I have to check if some files are present in asset folder. I use:

 string[]files=Directory.GetFiles(Application.dataPath+"someFolder","*.cs");

then if check the “file” by “File.Exists”:

  • in editor mode everything is ok and File.Exists(file) == true
  • in build the File.Exists(file) always return false

How to fix it?

or at least how to get all class string names from namespace2 like:

namespac1.namespace2.class1
namespac1*.*namespace2.class2

   Type[]types=Assembly.GetExecutingAssembly().GetTypes();

foreach(Type type intypes)
{
if(type.Namespace=="somenamespace"){

print(type.Name);
}
}

Okay got list of classes in namespace, but is it possible to check in build, what kind of files are in “editor” folder, in assets?

The editor file does not exist in the build. So you can’t check it.

1 Like

As I expected, so the only namespace approach will work, thanks!