FileUtil.CopyFileOrDirectory wont work

i came across a this bit of code on uity3d.com but it does not work at all .

static function CopyAFile () {

    // copies the file "YourFileOrFolder" from "path/" to "copy/path/"

    FileUtil.CopyFileOrDirectory ("path/YourFileOrFolder", "copy/path/YourFileOrFolder");
}

it should copy a file from one directory to another but i aways get this error.

The name `FileUtil’ does not exist in the current context

The name `CopyFileOrDirectory’ does not exist in the current context

Same Problem error CS0103: The name `FileUtil' does not exist in the current context

3 Answers

3

Its part of the UnityEditor namespace. I dont think it can be used in anything other than editor scripts

Yes. That example comes from the Editor API documentation.

same problem error CS0103: The name `FileUtil' does not exist in the current context

I added using UnityEditor;

Yep, but about this is there an equivalent to use it for your game ?
when you’ll try to build will simply not able to do it because it’s only editor, but unity docs doesn’t provide any information about the way to use it in a Build

Well, i fund the answer by myself finally, Using System; allow to use File.Delete(path _string); and many other things for the build