Unable to save changes to files in Visual Studio 2013

16,232

Solution 1

It turns out this was caused by disk encryption software. Disabling the disk encryption software services each time after starting VS2013 solves the problem. I did not have this problem with earlier versions of Visual Studio, presumably because of the new copy-replace cycle adopted by VS2013 mentioned in EDIT 2 in my original question.

Apologies for not coming back to comment and answer my original question, I completely forgot about it.

Solution 2

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

Solution 3

Try running Visual Studio as Administrator.

Solution 4

I had the same problem and it was caused by "Backup and Sync from Google". After I’ve closed it everything went back to normal.

Solution 5

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.

Share:
16,232
martijn_himself
Author by

martijn_himself

Updated on July 28, 2022

Comments

  • martijn_himself
    martijn_himself almost 2 years

    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.

  • martijn_himself
    martijn_himself about 10 years
    Thanks @mr992, upvoted. See EDIT 1 above, I don't think either file permissions or extensions are causing this but I may be wrong! Is there an easy way to view and disable extensions for a solution?
  • mrahhal
    mrahhal about 10 years
    @martijn_himself to be on the safe side, if you haven't already, go to Tools->Extensions and Updates... And disable all extensions. It's very common that VS creates and deletes temp files on the go. Are you experiencing this in all the solutions or only in this one?
  • mrahhal
    mrahhal about 10 years
    @martijn_himself did you check if there's the 'readonly' icon? It's like a small lock icon in the tab just after the file's name.
  • martijn_himself
    martijn_himself about 10 years
    Thanks for your comments. See EDIT 2. The file is checked out (there is no lock icon). I have also copied the solution and removed the bindings to source control but the problem remains. I am going to have a look to see what happens if I create new project from scratch (I have just installed VS2013 and this was the first project).
  • mrahhal
    mrahhal about 10 years
    @martijn_himself alright, if you haven't already add an exception to a folder in your antivirus, make a new project and try again. Make sure you add a global exception (for all the features). This depends on the antivirus you have. Also, don't enable the version control system you're using (tfs) just to be sure.
  • mrahhal
    mrahhal about 10 years
    @martijn_himself does this apply for ALL the files in your project? Did you add a new file and the same happened?
  • ThEpRoGrAmMiNgNoOb
    ThEpRoGrAmMiNgNoOb about 9 years
    hi. :) how can I disable the disk encryption software? Can you give me some steps? Thanks
  • Sean Kendle
    Sean Kendle over 7 years
    I love how people just stop back to say "I fixed it!" and don't say how. Like... ok, great for you, but you're just gloating.
  • robert
    robert over 7 years
    Have this same problem, but seems to be project specific. Creating and editing a new project does not have the problem when saving.
  • Cydaps
    Cydaps over 5 years
    Good catch! Was driving me insane, your suggestion sorted the issue immediately. Thanks!
  • Prolog
    Prolog about 4 years
    Once I thought that would be a good solution myself. In a result Visual Studio made all project files required with administrator permission. Had to clone whole project all over. Be advised.