Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-29
13:36 • Closed ticket [3006571fff]: error deleting: file already exists on Vista plu... artifact: 3d31d1ef26 user: jan.nijtmans
13:26
Fix [3006571]: error deleting: file already exists on Vista check-in: 4c56d701ab user: jan.nijtmans tags: core-8-6-branch
13:06
Fix [3006571]: error deleting: file already exists on Vista check-in: 102cd04c1f user: jan.nijtmans tags: core-9-0-branch
13:04
Fix [3006571]: error deleting: file already exists on Vista check-in: 82967ff42a user: jan.nijtmans tags: trunk, main
2026-10-23
10:06 • Ticket [3006571fff] error deleting: file already exists on Vista status stil... artifact: 0c43ed9bbc user: serhiy.storchaka
10:05
Fix [3006571fff]: [file delete -force] of a directory failed with "file already exists" when another... closed check-in: cfac6a1e07 user: serhiy.storchaka tags: win-delete-retry-not-empty
2013-01-17
18:54 • Ticket [3006571fff] error deleting: file already exists on Vista status stil... artifact: e25b11f6bc user: gahr
2010-09-03
16:56 • Ticket [3006571fff]: 4 changes artifact: 664cc96611 user: dunkfan
2010-05-25
01:28 • Ticket [3006571fff]: 4 changes artifact: 20e2d178fe user: pherricoxide
01:27 • Ticket [3006571fff]: 4 changes artifact: 3497c49279 user: pherricoxide
01:27 • Add attachment filedel.tcl to ticket [3006571fff] artifact: 83e5db7666 user: pherricoxide
2010-05-24
18:27 • New ticket [3006571fff] error deleting: file already exists on Vista. artifact: c2f83226b0 user: pherricoxide

error deleting: file already exists on Vista

Closed / Fixed3006571fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 34 days ago
Descriptionplain2010-05-24 18:27:04
On 2 Windows Vista machines I've tried running file delete -force will sometimes return the error, "error deleting filename: file already exists". This doesn't really make any sense, since of course the file exists or I wouldn't be deleting it. Attached is a script to show the problem and result files from two Vista machines. This is using TCL ActiveState ActiveTcl 8.5.8.0.291595 threaded.
Referenced by1
  • cfac6a1e07Fix [3006571fff]: [file delete -force] of a directory failed with "file already exists" when another process (e.g. a virus scanner or an indexer) kept a file in it open: the file was only marked for deletion, so the directory stayed non-empty for a moment. Retry removing the directory for up to about 1 s. Also use "/" in the whole path of the error message. check-in2026-10-23 10:05:41
pherricoxideplain2010-05-25 01:27:05
File Added - 375021: filedel.tcl
pherricoxideplain2010-05-25 01:28:15
Result of script,

Deleted C:/vvv
Deleted C:/vvv
error deleting "C:/vvv": file already exists
error deleting "C:/vvv\foo": permission denied
error deleting "C:/vvv\foo": permission denied
Deleted C:/vvv
Deleted C:/vvv
error deleting "C:/vvv": file already exists
Deleted C:/vvv
error deleting "C:/vvv": file already exists
Deleted C:/vvv
Deleted C:/vvv
Deleted C:/vvv
dunkfanplain2010-09-03 16:56:44
Also seen sporadically on Win7 64bit dual core machine. Tcl 8.5.5 threaded.
gahrplain2013-01-17 18:54:11
I'm also seeing this on 8.6.0 threaded, on a cifs-mounted filesystem. Workaround here is to retry after several msec.
serhiy.storchakawiki2026-10-23 10:06:30

Reproduced on 8.6, 9.0 and main under Wine, and on Windows 11 on an SMB share, when another process keeps a file in the tree open with FILE_SHARE_DELETE (as virus scanners and indexers do): the file is only marked for deletion, so removing its directory fails with ERROR_DIR_NOT_EMPTY, reported as "file already exists". Local NTFS on Windows 10 1903+ is not affected.

Proposed fix in branch win-delete-retry-not-empty: retry removing the directory for up to about 1 s, as suggested in the comment above. Also the path in the error message now uses "/" only.

jan.nijtmanswiki2026-10-29 13:36:55

Fixed in [trunk], core-9-0-branch and core.8.6.branch

Many thanks!

One closing '}' was placed wrong in your patch. Not a serious deal, but some compilers might still produce a warning on that .... spotted in time.

Log in (anonymous is fine) to add a comment.

Attachments: