How to check mapped network drive if exist by hostname C# -


i have problem in code c#. can not check mapped network drive if exist host name. can check ip address ping function. actual problem not ip address. need check hostname.

ping ping = new ping();  var reply = ping.send("ads-201");  if (reply.status == ipstatus.success) {    networkdrive onetdrive = new networkdrive();    onetdrive.localdrive = "z:";    onetdrive.sharename = "\\\\ads-201\\fileserver\\public";    onetdrive.mapdrive();  }  

this answer: friend figure out, sharing needs it.

var searcher = new managementobjectsearcher( "root\cimv2", "select * win32_mappedlogicaldisk"); list gunler = new list(); try { while (true) { thread.sleep(60 * 1 * 100); gunler.clear(); foreach (managementobject queryobj in searcher.get()) { gunler.add(queryobj["providername"].tostring().substring(2,7)); //messagebox.show("caption: " + queryobj["providername"] + " ---" + queryobj["filesystem"]); }

                // console.writeline("*** calling mymethod *** ");                 ipaddress ip = ipaddress.parse("192.168.1.123");                 //ipaddress hostn = ipaddress.parse("ads-201");                 ping ping = new ping();                 var reply = ping.send(ip);                // var hosreply = ping.send(hostn);                 if (reply.status == ipstatus.success)                 {                      if (gunler.contains("ads-201") || gunler.contains("ads-201"))                     {                         messagebox.show("ads-201 exist");                     }                     else                     {                         messagebox.show("ads-201 not exist!");                      }                    }                 else                 {                     messagebox.show("no ping hostname!");                 }                // yuor_method();             }         }         catch (exception ex)         {              messagebox.show(ex.message);        } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -