如何在使用过程中锁定文件并在使用PowerShell完成后将其解锁?

我有一个无限循环过程。我将检查一个文件,一旦文件存在,便对其进行处理。 如果我找到了文件,然后将其锁定,是否可以进行操作,这样人们将无法打开或修改文件,直到过程完成。

do{
     if(Test-Path -Path ".\Data.txt")
     {
          $file = Get-content -Path ".\Data.txt"
          ## do some process ##
          #
          #
          #
          #
          #modify the file extension to .don once
          # process
          #
          #FINISHED (the process will finished once the extension modified)
     }
}

while(1)

任何人都可以提出想法。谢谢。

iCMS 回答:如何在使用过程中锁定文件并在使用PowerShell完成后将其解锁?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2148403.html

大家都在问