0
\$\begingroup\$

When I try something like File.Delete("Assets/a.txt"); it gives me a error saying

Unknown identifier: 'File'.

In Unity Documentation https://docs.unity3d.com/ScriptReference/Windows.File.html it gives an note saying "this class is only available when targeting Universal Windows Platform." What does this mean?

In top of unity documentation it says File is a class in UnityEngine.Windows

So I tried Windows.File.delete("Assets/a.txt").

Now the error changed to

Language feature not implemented: UnityEngine.Windows.

What is it I am doing wrong?

\$\endgroup\$
  • 1
    \$\begingroup\$ As stated in the doc This is an alternative for System.IO.File class. Note: this class is only available when targeting Universal Windows Platform.. It is an alternative to System.IO.File and only works for MS Windows and Windows Phone. Why not just use System.IO.File? \$\endgroup\$ – Aditya Yadav Jul 24 '17 at 8:04
1
\$\begingroup\$

As the documentation states, the function you are trying to call is "only available when targeting the Universal Windows Platform," or UWP. You're not targeting that platform currently, and the function is unavailable to you.

UWP isn't "standard" Windows, it's a cross-device common application platform introduced with Windows 10. It's typically synonymous with "stuff that goes into the Windows app store."

So there's a good chance you don't want to be targeting UWP, since you don't need to, and should thus use a different API to delete a file such as the normal System.IO.File APIs.

If you really do need to target UWP, you'll have to modify your project appropriately to target the platform. Unity has some guides and tutorials on the subject.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.