-1

I'm new to creating extension in vscode. I am creating an extension that loads the file using 'fs' and make some changes to the file and write back the file. it works flawlessly for a file that is saved. But it shows:

Error: ENOENT: no such file or directory

for unsaved/untitled file. I used const loc = vscode.window.activeTextEditor.document.uri.fsPath;

can someone please help me how to get the location of unsaved/untitled file.

imnotiam
  • 94
  • 8

1 Answers1

0

An unsaved file does not and cannot have a path. It simply doesn't exist yet in the filesystem. When you create the editor, you will get a reference to the new content and that's it.

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181