c# - Check if File Exists on Remote Machine via Console Application -


first - still relatively new .net development. now, since that's out of way. making reporting console application go , access remote machines , check see if .png exists on every machine , report if image there or if there error, , error's message. reading in csv of ip addresses. currently, application read csv list. then, iterate on list appending ip address beginning of file path(i.e \\10.155.191.239\c$\programstuff\blahblah\storepcmenu\data\myassets\app_icons.png). @ beginning of console app, elicit user credentials. using .\desktop user credentials should sufficient trying do.

my problem > application reporting false negatives. also, if remote machine denies credentials, shows me generic error message , not message pertaining credentials denied.

we using pinvokewindowsnetworking class validate credentials. however, couldn't figure out how class report whether or not credentials actual problem. so, included managementscope class, able show me whether or not credentials validated (while using credentials other .\desktop). however, managementscope class not seem want work .\desktop credentials.

foreach (mystruct record in mylist) {     try     {         //managementscope myscope = new managementscope("\\\\" + record.myip + "\\root\\cimv2", myoptions);         managementscope myscope = new managementscope("\\\\"+ record.myip + "\\", myoptions);         myscope.connect();         if (myscope.isconnected == true)         {             try             {                 logentry = pinvokewindowsnetworking.connecttoremote("\\\\" + record.myip, uname, pword);                 if (file.exists("\\\\" + record.myip +eopath ))                 {                     output.writeline(record.store + " ," + record.myip + ", yes");                     console.writeline(record.store + " ," + record.myip + ", yes, " + datetime.now.tostring("yyyy-dd-m--hh-mm-ss"));                 }                 else if (!file.exists(record.path))                 {                     if (logentry.contains("error"))                     {                         output.writeline(record.store + ", " + record.myip + ", no, " + logentry);                         console.writeline(record.store + ", " + record.myip + ", no, " + datetime.now.tostring("yyyy-dd-m--hh-mm-ss") + ", " + logentry);                     }                     else                     {                         output.writeline(record.store + ", " + record.myip + ", no, file not found");                         console.writeline(record.store + ", " + record.myip + ", no, " + datetime.now.tostring("yyyy-dd-m--hh-mm-ss") + ", file not found");                     }                 }             }             catch (exception ex)             {                 output.writeline(record.store + ", " + record.myip + ", no, " + ex.message);                 console.writeline(record.store + ", " + record.myip + ", no, " + datetime.now.tostring("yyyy-dd-m--hh-mm-ss") + ", " + ex.message);             }         }     }     catch (exception ex)     {         output.writeline(record.store + ", " + record.myip + ", no, " + ex.message);         console.writeline(record.store + ", " + record.myip + ", no, " + datetime.now.tostring("yyyy-dd-m--hh-mm-ss") +", " + ex.message);     }         {         if (!logentry.contains("error"))         {             pinvokewindowsnetworking.disconnectremote("\\\\" + record.myip);         }     } 

any explanation of these 2 classes (other msdn links) or advice on use appreciated! need open , close socket between client , of these remote machines?


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -