VS Code extension – get full path

If you need the File use uri.fsPath
If you need the Workspace Folder use uri.path

if(vscode.workspace.workspaceFolders !== undefined) {
    let wf = vscode.workspace.workspaceFolders[0].uri.path ;
    let f = vscode.workspace.workspaceFolders[0].uri.fsPath ; 

    message = `YOUR-EXTENSION: folder: ${wf} - ${f}` ;

    vscode.window.showInformationMessage(message);
} 
else {
    message = "YOUR-EXTENSION: Working folder not found, open a folder an try again" ;

    vscode.window.showErrorMessage(message);
}

More detail can get from VS Code API

Leave a Comment