55

I am trying to edit a .CFG file in Notepad++. When I try to save it, it shows an error:

Check if file is open in another program.

Previously, I have had no problem editing the configuration files or with saving my changes. To fix this problem, I have tried closing all other open windows, restarting Notepad++, and restarting my computer. Unfortunately, none of this allowes me to edit the file.

3

8 Answers 8

92

Had the same problem when setting up apache webserver and php. Found out that this is due to the UAC in windows 7. It's is not because you have the file open anywhere else. Try opening Notepad++ as administrator. Either right click Notepad++ shortcut and choose run as admin or ctrl+shift and click notepad++ shortcut. Then open the file you want to edit from within notepad++.

This solved the problem for me.

7
  • 1
    can you backup your answer with some kind of source and/or other peoples' experiences about this issue? Mar 29, 2013 at 9:45
  • +1 for pointing out that it's UAC. I've seen this before.
    – MDT Guy
    Dec 18, 2013 at 16:21
  • 2
    The more standard way to handle UAC problems like this on a single file basis is to go ahead and save the file to somewhere else, like the Desktop, and then drag and drop the file to the proper directory (as Explorer can auto-elevate). This is what Microsoft recommends, for example. Opening as administrator is probably better reserved for when you need to save multiple files or save multiple times.
    – trlkly
    Jun 1, 2014 at 22:20
  • @LorenzoVonMatterhorn, I just did what Johan said an it worked, so you now have another source. Nice username =).
    – Tomás Cot
    Jun 24, 2016 at 0:09
  • doesn't help (only sometimes)
    – user25
    Aug 1, 2017 at 8:25
14

One possible problem is that the file is open via the explorer Preview pane, select a different file in the preview pane or disable the preview pane completly.

I just had this issue and it was due to having the file selected inside of Windows Explorer - the directory browser. It shows a preview of the file and I guess that causes Notepad++ to see it as being open.

6
  • Confirmed repro—on unselecting the file in Windows Explorer, the file could be opened again. Not the only cause of this error, but worth checking. Dec 18, 2013 at 15:59
  • 1
    This is not just I Notepad++ thing either. It seems just having the file selected in Windows Explorer marks the file as opened and can not be saved. Jan 21, 2014 at 15:05
  • 2
    Yup, it's pretty perverse that Windows Explorer's preview pane can lock files. Really counter-intuitive, very confusing and so easy to fall foul of. Jan 21, 2014 at 22:57
  • It's inconsistent. Somet.imes it locks, and sometimes not, but closing the preview gets rid of the problem. Sep 16, 2014 at 16:30
  • Does this still occur in W10?
    – William
    Feb 8, 2017 at 17:59
8

Sysinternal's Process Explorer will allow you (amon many other neat things) to find out all the processes accessing a given path. To do this, once Process Explorer is started, press CTRL+F (or open menu Find - Find Handle), and then type the relevant path (ex: c:\some\path\to\file.cfg), and it will show you which process have this opened.

Usefull, for example, to find which process is accessing a drive you try to unmount: just search for x: and it will show you every process accessing drive x: (or it's subpath))

3

Avira (Free) Antivirus also blocks the modification of some files

e.g. C:\Windows\System32\drivers\etc\hosts

if you have Avira Antivirus try to disable "Real Time Protection" and try again.

1
1

permission of admin (Operating System User), as been blocked. So log-in as admin and give share permission to anther user(where you want to edit).

1

Its Kaspersky doing its stuff. The solution is by adding Notepad++ to Trusted group.
Actually , Kaspersky is supposed to report/popup message whenever it blocks program but in this case it doesn't.

1

I had the same issue trying to delete a .html file.

I had "Preview pane" ON in Windows Explorer (Windows 10) and the file was selected, which meant it was being previewed as html in "Preview Pane". So I kept getting the error when trying to delete it.

As soon as I unselected "Preview Pane" (under View tab) I was able to delete it.

0

It could be several causes:

  • Another program has opened the file. But in your case this do not apply since you already restarted the system.
  • You don't have permissions to access the file. Try moving it somewhere, or "Save as..." then replace the original with the new one.
  • You shouldn't been touching the file. If you are trying to edit something in \Windows, is probable that the warning means that you really shouldn't touch that.

You must log in to answer this question.