And when I press Upload, a folder is created with my username, instead of the file I have selected.
The selected file is chosen from my Documents folder.
Thank you both for clarifying. This is my first attempt to make a powershell gui, so any help and claryfication is appriciated.
@oBda
Your changes did the job, but as with so many other aspects in life, one answer rises two new questions :-)
I have tried to add a simple error handling, where I check if the source and destination files have the same hash.
When the form is loaded, I dont want to show any text in $lblResult, but after I have submitted the file, I want to show one of the messages, depending on the result of the hash-check. But nothing happens.
With my limited understanding of the GUI concept, I would guess that I could put the refresh part in where i did, but...
$sourceHash = Get-FileHash $FilePath $destHash = Get-FileHash "$destPath\Test.csv" if($sourceHash -eq $destHash) { $lblResult.text = "Filen er nu overført til $FilePath" $lblResult.ForeColor = '#009933' $PuzzelFileUpload.Refresh() } ELSE { $lblResult.text = "Filen er IKKE nu overført" $lblResult.ForeColor = '#ff0000' $PuzzelFileUpload.Refresh() }
@oBda
Your changes did the job, but as with so many other aspects in life, one answer rises two new questions :-)
I have tried to add a simple error handling, where I check if the source and destination files have the same hash.
When the form is loaded, I dont want to show any text in $lblResult, but after I have submitted the file, I want to show one of the messages, depending on the result of the hash-check. But nothing happens.
With my limited understanding of the GUI concept, I would guess that I could put the refresh part in where i did, but...
Open in new window
Complete script here:Open in new window