Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
cannot save new generated file vscode extension

I'm trying to make a vscode extension. One functionnality it will need is creating a new file that the user can modify and then save. I use the following code to do so :

export async function linkA() {

const newFile = Uri.parse('untitled:' + path.join(workspace.workspaceFolders![0].uri.path + "/templates", 'filename.txt'));

workspace.openTextDocument(newFile).then(async document => {

    const edit = new WorkspaceEdit();

    edit.insert(newFile, new Position(0, 0), "Hello world!");

    return workspace.applyEdit(edit).then(success => {
        if (success) {
            window.showTextDocument(document);
        } else {
            window.showInformationMessage('Error!');
        }
    }); });}

When the function linkA is called, this does open a new file "filename.txt" and I can edit it. But when I try to save it I get the following error message (as a vscode information window ) : Failed to save 'filename.txt': Unable to write file '\c:\Users\RAM\Desktop\vscode-extension-samples\helloworld-sample\templates\filename.txt' (EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open '\c:\Users\RAM\Desktop\vscode-extension-samples\helloworld-sample\templates\filename.txt').

Anybody knows how to fix this ?

Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!