Powershell - Check if file is finished writing -


i have powershell code acts file listener on given folder path. listener kicks off command line call program opens , plays file.

the problem powershell code kicks off command line call if file put folder. problem if file large (say 100+mb) because when person copies file folder, file may 5% done 'writing' when command function kicks off , tries open file (and fails).

is there way in powershell check if file still being written too? way build loop check every x seconds , run once write completed?

does file maintain "lock" if being written too? can checked in powershell?

thanks everyone!

there may lock check available in system.io.fileinfo, or somewhere use simple length check. goes in called script not file watcher script.

$lastlength = 1 $newlength = (get-item $filename).length while ($newlength -ne $lastlength) {    $lastlength = $newlength    start-sleep -seconds 60    $newlength = (get-item $filename).length } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -