Why am I getting the error: An error occurred while trying to create a file in the destination directory - visual-studio-code

I don't know why I am getting this error suddenly whilst using vs code. Please help me, Thanks in advance.
P.S(I don't think files can be created in an exe right? I'm not sure after seeing this. Maybe do I have to specify where the file should be created and if yes, please tell me how. Else I'm looking for another answer)
(Edit): I tried downloading the system installation instead of the user installation. The system installer installs for all users on the system and needs administrator privileges unlike the user installer which install vs code only the particular user installing it.
Thanks, Codestrip
error

my solution for this was to set it to always start as administrator, I don't feel like reinstalling vscode (newly installed)
It's not a great solution for those who have multiple users, but I got rid of the error.
Ah, I saw that was a problem within User Permission, there were only 2 options checked. https://prnt.sc/uV-bF_q52Y3Y
I hope my solution will help you.

If you run your "vscode" as admin then you won't see this error
anymore.
Go to your "vscode" install location
If not sure then open the start menu.
Write vscode.
Right click on the icon and click "Open File Location".
In a new window there will be again an icon for the "vscode" right click on the icon
Again and click "open file location".
In another window, there will be an actual vscode's "exe" file.
Right-click on this file and go to the "send" > "send on desktop" option.
On the Desktop right-click on the icon and go to the properties
Click on Advance Option and Check the "Run as Admin" Option
Click Apply and Ok.
Now if you want Right Click on this icon again and select "pin to taskbar".
Hopefully, you won't see this error again.

I also encountered this error.
I tried remove the folder Microsoft VS Code inside C:\Users\<your username>\AppData\Local\Programs, and problem seems resloved

I had the same issue. But I fixed it. just go to this link and add take ownership to your context menu.
https://www.tenforums.com/tutorials/3841-add-take-ownership-context-menu-windows-10-a.html
After adding take ownership just go to vs code main directory and right-click on the Microsoft VS Code folder then press take ownership. After that your problem will be solved.

Related

How to change folder that opened by default in VSCode?

I have small problem with VSCode folder, that opened by default.
Problem description: I start new instance of VSCode (trough File->New Window), and then if I choose File->Open Folder it opens dialog with my Windows user folder as starting point (C:\Users\MyUser)
Question: How can I change that folder in settings (if it possible)? So by default it will show as start point for example D:\development\ ?
At the time I write this answer, this is not possible. There are two problems on Windows, and one problem on Mac and Linux:
VS Code does not provide a default path to the file dialog 1. It does remember the last folder that you opened a file in, but that path cannot be used as a default because it is overwritten constantly.
On Windows only, Electron ignores the default path when creating a file dialog if the default path is a directory 2.
An extension also cannot solve this, because extensions are not allowed to modify the File menu 3.
I think the best option at this point is to pin a folder to the Quick Access area in Windows Explorer, as suggested in a comment, or to put an actual shortcut in the user profile folder.
Workspaces and File > Open Recent may also be helpful if you often open the same folders.
Your main problem is that you are unable to open your specific folder in VScode.
To solve that you can simply open the terminal/cmd in that specific window by just typing cmd in your search bar or just by pressing shift+right-click in that folder.
Now your cmd is open and you just have to type "code ." in the cmd and press enter to open the current folder in your VSCode.
In case that code . doesn't work for you then you have to add the Vscode in the environment variables of your windows.
Visual Studio doesn't provide a specific feature to open a specific path. But there is a solution to your problem. You are saying that you want D:\develpment as a default when you open VS Code. You can go to that specific directory or create shortcut to desktop then click right click on that folder and then click on open with code. If you didnot see open with code then reinstall your VS code and check on open with code when you are reinstalling VS Code.
make a shortcut on the desktop for vscode and then modify it and add the folder after the .exe command. This will default open that folder when you double click on it.
Visual Studio Code can be installed in two ways - User setup and System setup. I strongly believe you have User setup installed in your PC. Try re-installing it System-wide. That should probably fix your problem.
For more information: https://code.visualstudio.com/docs/setup/windows#_user-setup-versus-system-setup
PS: A lot more information is needed, you can share a screenshot of the window and elaborate more on it.

How come I can't open my .html with Live Server in VSCode?

I installed Live Server in VSCode for the first time and am trying to open an .html file with Live Server. I'm following the simple instructions provided here on the official installation page, but to no avail.
I right-click my file in the Explorer as instructed, but "Open With Live Server" doesn't show. I've even tried right-clicking the tab and that doesn't work either. I've quit and re-started VSCode and that didn't work. I set Chrome as my default browser in settings.json and that didn't work. I double checked to make sure Live Server is installed and enabled globally and it is. Please help me figure out what's going on! Thank you!
Oh! I figured it out. I had to open my file by selecting "Open Folder" and then open my folder from there. Then I was able to select my file under the Explorer tab and right-click to open with Live Server. I'm not sure why it worked that way.
It's happened to me few times. My problem was the folder and files names.
Check those names and don't use spaces or weird characters.

How Can I Always Reset My Workplace Settings for Every Time I Quit VS Code?

What I want is to have all of my workplace preferences reset every time I quit VS Code. Right now, if I quit the application and opened the same folder I previously closed, VS Code still retains all pointer positions and all opened files. This maybe good for a lot of people, but for me, I just feel overwhelmed.
What I have tried:
I tried to locate .vscode folder but it is non-existent in my project folder.
"Clear Command History" doesn't work.
"Clear Editor History" doesn't work.
Following this link ---> https://github.com/Microsoft/vscode/issues/42948 and deleting /home//.config/Code/Local Storage doesn't work.
Following this link ---> https://github.com/Microsoft/vscode/issues/42948 and running window.localStorage.clear() in Electron development console returns undefined.
I am using Ubuntu 18.04.
In the settings menu you can search for window.restoreWindows and change that to none. You can also change workbench.editor.restoreViewState to false which might also help.

Cannot delete folder in Visual Studio Code definitely

I deleted a folder in Visual Studio Code to recreate it. But each time it recovers all files whereas I just want to create a new empty folder with same name.
This is a common issue that I am also facing for more then a year now and I am unable to find an open issue about this on Github. Every issue related to this that is opened gets closed because the developers are unable to find the source of the problem.
One way I could sometimes replicate the issue is to:
Open the project folder in Windows Explorer
Search for something inside VSCode that is contained in the folder
you are going to delete.
Try to delete the folder in VSCode.
Folder is not deleted.
Clearing the search after does not solve the issue. Most of the times I have to close and reopen VSCode.
Another ridiculous part is that the VSCode sends the file to the OS Trash and you are unable to undo the deletion when it works (CRTL + Z). VSCode is being pushed to the community by many developers but is really an infant editing tool that is terrible, the only amazing part of it is the huge ammount of plugins.
This is a long lasting bug that occurs ALL THE TIME with me. I know this is not a valid answer, but it's what I know about this problem this far.
i had the same problem. But works turn off malwarebytes. Maybe another antivirus is blocking to delete folders to, try this.
Try running Visual Studio in Administrator mode. It worked for me.
It took 6 hours to find out that.... it can be deleted by VsCode file explorer, if i try to delete it manually it juggles with admin permission and user permission back and fourth.
Just delete the folder from VSCODE file explorer from the left menu.
I just restart my mac and everything went well after that 🤞
i had the same problem. I go to Terminal and turn off all powershell,a voala I finally can delete folder from VS explorer.

Install VSCode in a specific folder

I just downloaded the Visual Studio Code App from https://code.visualstudio.com/ and when I tried to install it, it simply just installed it by itself, without the option to change the installation path.
I have an external harddrive, which is where I want the IDE to be placed instead of the Local Harddrive. How can I change this?
On the VSCode download page select "System Installer" instead of "User Installer". The System installer will prompt you for the install location.
Full credit to Hans Passant for giving the following working solution as a comment.
The installer does very little beyond copying the files, it just creates some Explorer context menu shortcuts ("Open with Code"). Otherwise following Chromium conventions and copying itself to c:\Users\yourname\AppData\Local\Code\app-0.1.0 so it can update itself without you noticing. Boo. So high odds that simply moving that folder to the other drive works just fine, put it anywhere and create a shortcut to Code.exe. If you still want the context menu entry to work then use Regedit and search for "code\app-0.1.0".