powershell - Converting byte array to true/false -


through various different posts on stackoverflow , other places able put powershell script ftp uploads files , works great. wanted add bit more verbosity it. see code below:

foreach ($file in $uploadfiles) {  # create full path file on remote server (odd okay!) $ftp_command = $ftp + $file  # debugging #$ftp_command  # create new uri object full path of file $uri = new-object system.uri($ftp_command)  #for debugging #$uri  # our upload remote server - uri object, full path local file #$responsearray = $ftpclient.uploadfile($uri,$file.fullname)    $result = $ftpclient.uploadfile($uri,$file.fullname)     if ($result) {     $file.fullname + " uploaded successfully" } else {     $file.fullname + " not uploaded successfully" }  } 

basically after file uploaded wanted check , see if successful or not. upload file supposed return byte array ( http://msdn.microsoft.com/en-us/library/36s52zhs(v=vs.80).aspx ; a byte array containing body of response resource.). i'm new powershell that's problem is, life of me can't come out of $result can test. possible server isn't returning or i'm not accessing/setting the byte array correctly? i've tried variety of different things, haven't yet figured out.

thanks,

i not use $result in case begining powershell 2.0 can use try/catch sections.

try {   $ftpclient.uploadfile($uri,$file.fullname) } catch [system.net.webexception] {  # here $_ gives exception details } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -