'Why do my files in vscode keep being deleted after trying to execute them?
I am currently learning to code with python in vscode but recently I have been having problems with file seemingly deleting themselves after attempted execution (image 1). I have tried Ctrl+z and I have tried recovering them but neither have worked. The files are not in my recycling bin either. If I try to create a new file of the same name in the same folder it shows me a error message (image 2) of "unable to resolve non-existing files"
When I execute my code the file saves but then becomes deleted:
This message appears if I try to undo the delete:
Solution 1:[1]
Try running the Python file through a command prompt or terminal using the command python <foo_file_name>
. Doing this will either confirm or deny the theory that @jasonharper made in the comments.
If you can run the script that way then we know that @jasonharper was correct and somehow your execute button/command was tampered with.
Solution 2:[2]
Have you tried to restart vscode? It is recommended that you could try the following aspects:
- Check if there is any effect caused by the related expansion. For example, LaTeX Workshop extension has the function of cleaning generated files.
- Check your setting.json Files,clear the contents of the user setting.json file and the vs code will return to the default value.
If it still doesn't work, you could consider installing vscode again.
Solution 3:[3]
I had a similar issue using a different programming language. Building generated a file that got deleted automatically. In my case the Windows 10 default antivirus was the cause. Turned off real-time scanning, tried again and then my files weren't deleted. Adding an exception for the folder fixed it.
Solution 4:[4]
I had the Same problem with a PHP file, and turns out it wasn´t VS CODE. It was my antivirus that was moving the file to quarentine!!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | griffin_cosgrove |
Solution 2 | Jill Cheng |
Solution 3 | stoerp |
Solution 4 | Otávio T. |