Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to save changes to files in Visual Studio 2013

I have a Visual Studio 2013 solution that is under source control (TFS, Visual Studio Online). It is mapped to a local workspace, I have checked out some files (e.g. web.config, global.asax).

When I try to save any changes to files I get a 'Save File As' dialog, and if I hit Save it warns me the file already exists (say, web.config), and asks me if I want to replace it. If I hit Yes I get I get an error dialog saying 'the process cannot access the file '....\wyfvmjia.p1p~' because it is used by another process. I have no idea what this file is or how it is related to the file (web.config) I am trying to save.

This is infuriating, any help would be greatly appreciated!

EDIT 1:

It looks like the Visual Studio process (devenv.exe) is creating and deleting random temporary files in the same folder (e.g. wyfvmjia.p1p~) and is causing a 'sharing violation' on those files (I used a sys internals utility to monitor the folder) when I am trying to save let's say web.config.

EDIT 2:

This seems to suggest in one of the comments that VS2013 creates a copy of a file and then replaces the original when trying to save a file in your project. This would explain why I see temporary files getting created and deleted. It's odd I get the 'Save File As' dialog though. It looks like some other process (antivirus?) gets hold of the temporary file before VS can do something with it?

EDIT 3:

I created a console application project with only a program.cs file and the same is happening. This may be a problem with Antivirus software interfering with the VS2013 'copy-replace' feature.

EDIT 4:

Changed title. Still have not been able to find a solution.

EDIT 5:

See the accepted answer. Apologies for not getting back earlier.

like image 843
martijn_himself Avatar asked Apr 05 '14 15:04

martijn_himself


People also ask

How do I save changes in Visual Studio?

By default, VS Code requires an explicit action to save your changes to disk, Ctrl+S. However, it's easy to turn on Auto Save , which will save your changes after a configured delay or when focus leaves the editor. With this option turned on, there is no need to explicitly save the file.

How do I enable autosave in Visual Studio?

In case of any saving failure (may occur after all VS is also a software), the Visual studio will keep the your changes unsaved. To enable it, Go to Tools -> Options -> Environment -> Documents -> Automatically save files when Visual Studio is in the background. (Please note, this is Visual Studio 2022 17.2.

How do you save in visual?

From the File menu, choose Save File As, and then click the drop-down button next to the Save button. The Advanced Save Options dialog box is displayed. Under Encoding, select the encoding to use for the file. Optionally, under Line endings, select the format for end-of-line characters.


3 Answers

For me it was Google Drive. Once I've closed it, I was able to save the file.

like image 82
Guy Biber Avatar answered Oct 08 '22 17:10

Guy Biber


Try running Visual Studio as Administrator.

like image 30
Marcelo Mason Avatar answered Oct 08 '22 16:10

Marcelo Mason


Extensions might be the problem. Or you could be opening some readonly files. It's worth to mention that some of the extensions can turn any file you create in to a readonly file, and this would be the same result that you're facing.

So first, disable all extensions, and check for the little icon near the files's name (in the tab) that indicates a readonly file.

like image 33
mrahhal Avatar answered Oct 08 '22 15:10

mrahhal