Renaming a file is something that we do very often, but in my case, I wanted to do it from within a Visual Studio Code extension. When I first looked at the APIs and available documentation, I found the vscode.executeDocumentRenameProvider
command and RenameProvider
.
InfoDocumentation from this can be found here built-in commands.
Now, I thought, there must be an easier way, so I started to look around at the APIs available, and luckily there is an easy option.
On the vscode, its workspace
namespace, you can access the fs
or file system via: vscode.workspace.fs
. The fs
instance delivers you a couple of valuable methods you could use, like rename
.
If you want to rename a file, you just need to use the rename
method as follows:
|
|