Let me see if I understand the situation:
- You have a file, let’s call it
original.txt
, open in Notepad++ - You use File > New to create a new tab in Notepad++, and then edit that new tab.
- You choose File > Save (or File > Save As…), and select the same path and name as
original.txt
- Notepad++ asks you if you want to replace it, and you say Yes
- Notepad++ informs you with an
ERROR
dialog that “The file is already opened in the Notepad++”
I concur, that is the current behavior (v7.5.8 32-bit).
To me, that seems a reasonable behavior. If you really want the contents of your new tab (labeled as new #
for some numeric value of #
) to be saved as a file you already have open, there are two easy options: 1) close the original tab, then do the Save/Save As… from the new #
tab; or 2) copy the contents from the new #
tab to the original.txt
tab, and do the Save from the existing original.txt
tab.
Okay, I just tried a couple of my older portable/standalone versions: at least as far back as v7.5.0, it’s been under the current behavior, so it’s not a recent change. Ah, there, v7.4.2 32-bit (from Jun 2017) shows the behavior you seem to want: When I say Yes on step #4, it does save… now I have two tabs in the same editor that claim to be the same file with the same name, and both claim to be saved, but one has the “original text that I typed”, and the other has the “new text that I saved overtop”, so there is introduced confusion over which is most recent. If you wait long enough, Notepad++ may recognize that the two are out of date, and update the old instance to the new instance.
Personally, I would find that situation (two copies of the same file that at times get out of date with each other) more confusing than the current situation.
But if the current behavior really bothers you, I would recommend you follow the instructions in this FAQ for submitting bug or feature requests, and say something like “back in v7.4.2, I could have original.txt
open, and create a new file, then use Save As to save the new file overtop of original.txt
, but from v7.5 thru the current v7.5.8, it tells me ERROR “The file is already opened in the Notepad++”
”, and ask if the development team can put the behavior back to the v7.4.2 behavior. It won’t guarantee that your request will be implemented, but it will put the request in the appropriate spot so it can be properly tracked.
Я пытаюсь редактировать .CFG
в Блокноте ++. Когда я пытаюсь сохранить его, он показывает ошибку:
Check if file is open in another program.
Ранее у меня не было проблем с редактированием файлов конфигурации или сохранением моих изменений. Чтобы решить эту проблему, я попытался закрыть все другие открытые окна, перезапустить Notepad++ и перезагрузить компьютер. К сожалению, ничего из этого не позволяет мне редактировать файл.
Была такая же проблема при настройке apache webserver и php. Выяснил, что это связано с UAC в windows 7. Это не потому, что у вас есть файл, открытый в другом месте. Попробуйте открыть Notepad++ с правами администратора. Либо щелкните правой кнопкой мыши ярлык Notepad++ и выберите команду «Запуск от имени администратора», либо нажмите Ctrl + Shift, а затем нажмите ярлык «Блокнот ++». Затем откройте файл, который вы хотите редактировать, в notepad ++.
Это решило проблему для меня.
Одной из возможных проблем является то, что файл открывается через панель предварительного просмотра проводника, выберите другой файл на панели предварительного просмотра или полностью отключите панель предварительного просмотра.
У меня только была эта проблема, и это было из-за того, что файл был выбран в Проводнике Windows – браузере каталогов. Он показывает предварительный просмотр файла, и я предполагаю, что это приводит к тому, что Notepad++ видит его открытым.
ответ дан Andrew Mallonee131
Обозреватель процессов Sysinternal позволит вам (среди множества других интересных вещей) выяснить все процессы, обращающиеся к заданному пути. Для этого после запуска Process Explorer нажмите CTRL+F (или откройте меню Find – Find Handle), а затем введите соответствующий путь (например, c:somepathtofile.cfg
), и он будет покажу вам, какой процесс уже открыт.
Полезно, например, чтобы узнать, какой процесс обращается к диску, который вы пытаетесь размонтировать: просто найдите x:
и он покажет вам каждый процесс, обращающийся к диску x:
(или его подпути))
ответ дан Olivier Dulac728
Avira (Free) Antivirus также блокирует изменение некоторых файлов
например, C:WindowsSystem32driversetchosts
если у вас есть Avira Antivirus, попробуйте отключить “Real Time Protection” и повторите попытку.
ответ дан Thorsten Niehues526
разрешение администратора (пользователя операционной системы), поскольку оно было заблокировано. Так войти в системе как администратор и дать разрешения на share
пыльников пользователя (где вы хотите редактировать).
Это может быть несколько причин:
- Другая программа открыла файл. Но в вашем случае это не относится, так как вы уже перезапустили систему.
- У вас нет прав доступа к файлу. Попробуйте переместить его куда-нибудь или «Сохранить как …», а затем заменить оригинал новым.
- Ты не должен был трогать файл. Если вы пытаетесь что-то отредактировать в
Windows
, вероятно, предупреждение означает, что вам действительно не следует это трогать.
Это Касперский делает свое дело. Решение заключается в добавлении Notepad++ в группу Trusted.
На самом деле, Kaspersky должен сообщать / всплывающее сообщение всякий раз, когда он блокирует программу, но в этом случае это не так.
-
Summary
-
Files
-
Reviews
-
Support
-
Patches
-
Discussion
Menu
▾
▴
-
Create Topic -
Stats Graph
Forums
-
[READ ONLY] 中文論壇
42 -
[READ ONLY] Quiting SourceForge
10 -
[READ ONLY] Translation
158 -
[READ ONLY] Foro en español
122 -
[READ ONLY] Plugin Development
1913 -
[READ ONLY] Forum français
816 -
[READ ONLY] Deutsch Forum
824 -
[READ ONLY] Fórum em português
114 -
[READ ONLY] Here to Boycott Notepad++
288 -
[READ ONLY] Scripting
126 -
[READ ONLY] Help
7028 -
[READ ONLY] Open Discussion
7147
Help
-
Formatting Help
Bug: saving as a file already open in Notepad
Created:
2010-04-01
Updated:
2012-11-13
-
Today I managed to save a new file with the same name as the original file I had already open in Notepad++ and copied the contents from to the new document.
I think this should not be allowed.
A lot of issues with this can be thought of, although I didn’t run into any, nor did I try to. I was aware of the “problem”.For instance, it wouldn’t be clear which file would represent the last saved state of the document. Thinking of this, as far as I can recall I did not get any message about the original document having been changed when the new version/copy was saved with the same name.
What was “correct”, was that after having closed both files, there was only one entry in the Recently Opened Files list.
-
What did you exactly do?
I tried to reproduce the issue by
* opening a file
* creating a new doc
* writing random stuff to it
* attempt to save, choosing the other doc as targetI got a message box asking me to confirm. Don’t you get the message box?
CChris
-
Yes, of course, the file already exists so I will have to confirm. But that is not the issue. This would also be the case if I didn’t already have the same file open in Notepad++.
The point is, I can have two documents (or more, I guess) in Notepad++ referring to the same actual file.
I could make changes in any document and save them and not know which document is the same as the actual file.If I would have unsaved changes in any of them and would close Notepad++, I guess I would be asked if I wanted to save the changes (any number of times) and end up not knowing what actually would have been saved last.
-
You can have he same document opened once in each view for a single instance. If you have several instances with an active buffer pointing to the same file, you are in charge of concurrency issues.
The latest versions of Notepad++ switch to the file they attempt to save on an exit. This will give you a clue if you can see some changes on the page being displayed. If a file has been changed in one view but not the other, you’ll be proplted once, and the changed ersion ill be written if no cancellation occurs.
Now the only issue imho: a file was changed in both views, and it is not obvious what set of changes is saved first. Please make a request describing how N++ is supposed to behave. My personal choice would be to cancel the save with a notification of the conflict between two versions of the file.
CChris
-
Split-view is of course not an issue, because both are only views to the very same document (buffer).
I think it should not be possible at all to have the same file (name) opened more than once inside a Notepad++ instance.
It is possible to open multiple regular Notepad instances of the same file, but what is the use? Just from switching between the instances, you can’t really tell which instance contains which changes or versions. Perhaps you could get an impression from the position in the task bar menu. But who would want this confusion. In regular Notepad you even have no indication at all if the file contents have changed. You will only find out by closing the instance by a save message appearing or not.
Of course, the issue of the ability to open multiple instances of the same file by using multiple instances of (several) editors will always remain. Most editors have a file-changed (outside of the editor) message with reload question, so this problem is (partially) solved.
In Notepad++ however, what happens when the file has changed to multiple instances within a single Notepad++?
First of all, the reload question(s) will only appear after returning from another application! So if I save several instances of a file (name), at first there will be no questions asked at all. I could make additional changes to any (other) instance of the file/document, save the instance, and still have no clue about which of the instances would contain the actual contents of the file.
If I have switched to another application and return to Notepad++ I guess it would not be clear at all which instance of the document I am asked to reload or not (I didn’t try). It would be a good thing if, like the “save” question on exiting Notepad++, Notepad++ would also show the document it is asking to reload.
But just to avoid all these issues (and possibly other issues caused by indicating documents by just using their filename), it would be best, most transparent and correct, to allow only one instance of the same file to be opened within the same Notepad++ instance.
-
And much more unpractical too.
I routinely use N++ to view several parts of a file at the same time, using split views and wishing I could have three or four views sometimes. You get this by opening several instances, losing any vetical sync between different instances of course – I can’t think of a way to achieve this.
You can’t open the same file twice in the same view, can you? So you have only two views of the same doc in the same N++ instance.
When you edit a document in both views, you are not editing two temporary copies of a master document, in which case you’d actually need a three-way merge on save. Instead, there is a single file, a singe document instance, and you can type a character in one view and delete it in the other. So there is no conflict after all.
Oh yes, there is. If you open a document in three different instances of N++ and save one of them, the other two will ask to reload, but the first request won’t know which of the other two instances changed the file. Sorry about this, but it looks a little outlandish.
CChris
-
> You can’t open the same file twice in the same view, can you?
> So you have only two views of the same doc in the same N++ instance.Split view is not the issue, again.
Again:
But just to avoid all these issues (and possibly other issues caused by indicating documents by just using their filename), it would be best, most transparent and correct, to allow only one instance of the same file to be opened within the same Notepad++ instance.
What I am saying is that is should not be possible to save a new file with the same name as a file already open in Notepad++.
When creating new copies, currently there is no limit to the number of files with the same name I can have open in Notepad++, possibly having all the problems mentioned above.
-
I think he means this:
1. Create a new document and write some stuff.
2. Save on desktop as “test.txt”
3. Create another new document and write some different stuff.
4. Save and replace the “test.txt” file previously saved.The two files are the exact same files, but two different buffers are used and therefore can cause problems. Especially if the user does not change applications to trigger a “modified file” search. Even then, you can then still edit either file and overwrite the other without knowing which is which. This can be done many times over to no end.
Closing and reopening N++ only opened one of the two instances, but the ability to do the above still exists
Solution? I’m not sure which is best. Here is what I have come up with.
Maybe close the first rendition, and keep the new one that the user agreed to overwrite the file with.
Merge both into the same buffer (potentially cause other problems, I’m not familiar with the code to know for certain)srbs
-
Ok, this one makes sense.
Merging the two files may not be adequate at all. But indeed I’d report a bug stating that the above sequence leads to the same file being open in different buffers in the same viw, possibly unbeknownst to the user.
CChris
-
#1
I use this code to test for files already opened by another user or process:
Code:
Function IsFileOpen(strFile As String) As Boolean
Dim i As Integer
i = FreeFile
If Dir(strFile) = "" Then IsFileOpen = False: Exit Function
Err = 0
On Error Resume Next
Open strFile For Binary Access Read Lock Read Write As #i
If Err Then IsFileOpen = True
Close #i
End Function
Works fine. However, if I have a text file open within Notepad (haven’t tested with other programs) on my computer (haven’t tested if it behaves the same way when another user has the file open in Notepad) and execute the function, the function returns False (ie suggesting file isn’t open). This line executes successfully:
Code:
Open strFile For Binary Access Read Lock Read Write As #i
I tested with this code with and without the target file being opened:
Code:
Sub test()
MsgBox IsFileOpen("C:TestTest.txt")
End Sub
Firstly, can someone else confirm whether this is the case for them, and secondly explain why this is the case – I would have thought the Open statement should produce an error (and thus the function to return True). Or does Notepad specifically not Lock the file it has opened? Or some other reason?
Thanks for any and all replies!