windows – 使用New-Item创建目录的竞争条件?
发布时间:2020-12-14 04:22:23 所属栏目:Windows 来源:网络整理
导读:我在调用New-Item以使用UNC路径在外部计算机上创建目录时看到了竞争条件.代码如下: New-Item $target -itemType Directory -Force -Verbose | %{ Write-Host "Creating dir" $_.FullName } 之后立即使用Test-Path返回false.我把测试路径 – 睡眠1秒重试循环
我在调用New-Item以使用UNC路径在外部计算机上创建目录时看到了竞争条件.代码如下:
New-Item $target -itemType Directory -Force -Verbose | %{ Write-Host "Creating dir" $_.FullName } 之后立即使用Test-Path返回false.我把测试路径 – >睡眠1秒重试循环,睡眠1秒后,Test-Path返回true. New-Item是阻止通话吗?我应该在打电话给New-Item后等待吗?
我无法重现你的问题.
PS > New-Item "test" -itemType Directory -Force -Verbose | %{ Test-Path $_.FullName } VERBOSE: Performing the operation "Create Directory" on target "Destination: C:UsersFrodeDesktoptest". True New-Item通过获取父目录的DirectoryInfo对象并将其调用为CreateSubDirectory来创建新目录,如: DirectoryInfo subdirectory = new DirectoryInfo(parentPath).CreateSubdirectory(childName); 我不是开发人员,但AFAIK意味着它是一个阻塞调用,因为它等待一个DirectoryInfo对象作为回报.所以mabe的问题在于您的存储子系统. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Windows10主机插入耳机只有一边有声音
- window下解决fastdfs_client安装报错问题
- 带有ANSI代码的文本编辑器/查看器,支持Windows
- wpf – 在Window的MenuItem上动态绑定到ViewModel命令
- 如何在Windows 7及更高版本中查找和安装CIM Studio?
- windows – 如何自动更改Ephemeral驱动器的指定字母?
- windows-server-2008 – 强制Windows Server 2008使用旧版B
- Windows窗体中的打印面板C#
- windows-server-2008-r2 – Windows 2008 R2如何运行32位应
- active-directory – 如果Windows商店将“所有内容”移动到