在 TCL 中使用 "file mkdir" 时,出现文件夹不存在的错误,但这就是我要创建它的原因。

When using "file mkdir" in TCL i get the error that the folder does not exist, but thats why i want to create it..

我在 Windows 7 计算机上创建 TCL8.5.9 目录时遇到了一些问题。

set CurrentDir          [ file dirname $GUI_DB_path]
set ImageFolderPath     [ file join $CurrentDir "DeflectionPlots" ]
# Always try to delete the Folder no matter if it exists or not
file delete -force      $ImageFolderPath

# sometimes the following throws an error. Do not understand why.
# Create a clean and empty ImageFolder
file mkdir              $ImageFolderPath

有时,但并非总是如此,我会收到错误消息:

无法创建目录.....$ImageFolderPath.....没有那个文件或目录

嗯,这就是我想要创建它的原因。 运行 第二次不做任何更改的代码会根据需要创建目录。是什么原因造成的,我该如何解决这个问题?我可以捕捉到错误,但我仍然不会创建我的文件夹。

Windows 文件操作(或它们的内部锁定)通常很慢。

我 运行 遇到像你这样的问题 deletions/new files/renames 一会儿然后我得到错误,因为文件在某种程度上 操作系统不稳定。

您可以在删除和创建之间添加一个短暂的休眠 应该在 Windows.

上解决问题
set ::img_create_sleep 0
after 200 [list set ::img_create_sleep 1]
vwait ::img_create_sleep