Code: Select all
$buttonBrowseFolder_Click = {
if ($folderbrowserdialog2.ShowDialog() -eq 'OK'){
$textboxFolder.Text = $folderbrowserdialog2.SelectedPath
$Back_Rec_Path = $folderbrowserdialog2.SelectedPath
Update-ListBox $ListBox1 "create Backup Directory / read Backup Directory" -Append
$global:DestPath = [system.io.path]::Combine($Back_Rec_Path,'BACKUP', $Env:USERNAME)
Update-ListBox $ListBox1 "create Log Folder / read Log Folder" -Append
$global:DestPathLog = $DestPath + "\!LOG" #
$global:LogFile = $DestPathLog + "\Robocopy_Profil_copy.txt"
If (!(test-path $DestpathLog)){ #sollte das Zielverzeichnis nicht vorhanden sein, läuft Robocopy wegen der LOG-Datei in einen Fehler...
New-Item -ItemType Directory -Force -Path $DestpathLog
}
}
}
If "Test-Path" fails you are doing nothing. You need to do something when the path does not exist.