How do I change a file extension programmatically?

I have a file in my Resources folder named “image.pcx”.

I want to change the file name to “image.txt” so that I can load it.

How can I change the file name?

I was unsuccessful with:

AssetDatabase.RenameAsset("Assets/Resources/image.pcx", "image.txt");

As it renamed it to “image.txt.pcx”.

Hello @Evorlor,

You can use File.Move(string src, string dst) to do it.

Ex:
File.Move (“Assets/Game/isound/Resources/icon_button.bytes”, “Assets/Game/isound/texture/NGUI/icon_button.png”);