Notepad++ says "Check if file is open in another program" - but no other program is open

53

8

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.

user1933617

Posted 2012-12-28T04:21:01.117

Reputation:

Mine was Zone Alarm locking the hosts file, one of it's advanced settings. See here: https://superuser.com/a/1104284/145568

– Arth – 2018-06-21T09:37:37.940

5

See if you can copy the file elsewhere, edit, then overwrite the original. If not, use Process Explorer or a program similar to Unlocker to figure out what's locked the file.

– Karan – 2012-12-28T21:28:48.860

Similar one is answered here: http://stackoverflow.com/q/2763067/948268

– Kuldeep Jain – 2014-02-25T14:28:45.303

Answers

89

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.

Johan

Posted 2012-12-28T04:21:01.117

Reputation: 891

@LorenzoVonMatterhorn, I just did what Johan said an it worked, so you now have another source. Nice username =). – Tomás Cot – 2016-06-24T00:09:41.107

doesn't help (only sometimes) – user25 – 2017-08-01T08:25:35.170

Newer versions of notepad++ prompts to run in Administration mode, but my version just shows the message from the post. On the machine was Notepad++ 6.7.4 - Je suis Charlie edition – mihkov – 2019-10-17T08:23:05.943

In my case explorer.exe was holding a lock on the file (not sure why) and Admin mode doesn't help in this case. the answer from Olivier Dulac really helped https://superuser.com/a/525237/423284. Also, see here for a more generalized answer for file lock issues: https://helpcenter.gsx.com/hc/en-us/articles/115015880627-How-to-Identify-which-Windows-Process-is-Locking-a-File-or-Folder

– blackstrype – 2020-01-07T15:14:48.687

1can you backup your answer with some kind of source and/or other peoples' experiences about this issue? – Lorenzo Von Matterhorn – 2013-03-29T09:45:11.070

+1 for pointing out that it's UAC. I've seen this before. – MDT Guy – 2013-12-18T16:21:59.007

2The 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 – 2014-06-01T22:20:32.827

13

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.

Andrew Mallonee

Posted 2012-12-28T04:21:01.117

Reputation: 231

It's inconsistent. Somet.imes it locks, and sometimes not, but closing the preview gets rid of the problem. – Dominic Cronin – 2014-09-16T16:30:45.923

Does this still occur in W10? – William – 2017-02-08T17:59:42.777

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. – Jordan Gray – 2013-12-18T15:59:39.987

1This 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. – Andrew Mallonee – 2014-01-21T15:05:35.360

2Yup, 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. – Jordan Gray – 2014-01-21T22:57:07.340

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))

Olivier Dulac

Posted 2012-12-28T04:21:01.117

Reputation: 818

2

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.

Thorsten Niehues

Posted 2012-12-28T04:21:01.117

Reputation: 981

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).

KarSho

Posted 2012-12-28T04:21:01.117

Reputation: 137

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.

Braiam

Posted 2012-12-28T04:21:01.117

Reputation: 4 526

0

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.

user1502776

Posted 2012-12-28T04:21:01.117

Reputation: 493