Here are examples of various paths returned by vscode in windows:
Extension path:
vscode.extensions.getExtension('extension.id').extensionUri.path
> /c:/Users/name/GitHub/extensionFolder
vscode.extensions.getExtension('extension.id').extensionUri.fsPath
> c:\Users\name\GitHub\extensionFolder
Current folder:
vscode.workspace.workspaceFolders[0].uri.path
> /c:/Users/name/Documents/Notes
vscode.workspace.workspaceFolders[0].uri.fsPath
> c:\Users\name\Documents\Notes
Current editor file:
vscode.window.activeTextEditor.document.uri.path
> /c:/Users/name/Documents/Notes/temp.md
vscode.window.activeTextEditor.document.uri.fsPath
> c:\Users\name\Documents\Notes\temp.md
Note that path
and fsPath
refer to the same folder. fsPath provides the path in the form appropriate for the os.