If there are 3 PCs on the network and if I want to find a description of freespace and disc from a PC with any other PC How to go about it .... I got this code. But I do not know how it can check whether it is working or not. This is the right way .. This is the right way ..
Public HashTable ReadFreeSpaceOnNetworkDrives () {// Create Hashtable Example to keep our informationStextableDefinfo = newHashTable (); // win32_logicaldisk query for type 4 (network drive) SelectQuery query = new selector ("select name, freepace from win32_logicaldisk where drivetype = 4"); // WMI ManagementObjectSearcher Explorers = Execute the query using new Management Object Search (query); // mixed with loop through each drive (Management Object Drive in the Finder) (Get) ()) {// Name & amp; Freespace ("drive", drive ["name"]) to INFO.Add to our hashtable drive; DriveInfo.Add ("Space", Drive ["FreeSpace"]); } INFO return drive; } Update:
I got an answer to my question, but I got the code but it is in the console and with a graphical form of Windows Applying Disk space and drive information representation How can I use this code and can I go about doing this?
Management Scope Scope = New ManagementScope ("\\\\ 10.74.160.126 \\ root \\ cimv2"); Scope.Connect (); Object query = new object ("Select * from Win32_OperatingSystem"); SelectQuery query1 = Select new ("Choose * from Win32_LogicalDisk"); Management object explorer explorers = new management object search (scope, query); Management Object Collection Query = Explorers gate (); Management object explorer explorers = new management object search (region, query1); Management Object Query Query Collection 1 = Finder 1 gate (); Foreach (Queryoxide ManagementObject) {// Remote Computer Information Console Display WrightLine ("Computer Name: {0}", m ["csname"]); Console WrightLine ("Windows directory: {0}", I ["WindowsDirectory"]); Console.lightline ("operating system: {0}", m ["caption"]); Console.lightline ("version: {0}", m ["version"]); Console.light line ("creator: {0}", me ["creator"]); Console.WriteLine (); } Foreach (Query 1 in Management Object Query) {Console.WriteLine ("Disk name: {0}", mo ["name"]); Console.light line ("disk size: {0}", mo ["size"]); Console.light line ("freyspace: {0}", mo ["freyspace"]); Console.light line ("disk device id: {0}", mo ["device id"]); Console.light line ("disk volume: {0}", mo ["volume name"]); Console.light line ("disk system name: {0}", mo ["system name"]); Console.light line ("disk volume number: {0}", mo ["volscierial number"]); Console.WriteLine (); } Console. Readline (); Code
The code checks all drives on the PC, where you run this program. It gives a table with 2 entries per drive with a name and with a blank space. You can write a simple program that uses this method and display this data. It is possible to query the drive from a remote computer. This article may tell you more
Edit:
Public HashTable Reed Free SpaceOnworkDrives (String FULL ComputerName) {ManagementScope Scope = New ManagementScope (Full ComputerName); Scope.Connect (); // To maintain our information, prepare the example of hashtable. Hashtable drive INFO = new hashtable (); // win32_logicaldisk query for type 4 (network drive) SelectQuery query = new selector ("select name, freepace from win32_logicaldisk where drivetype = 4"); // WMI Management object explorer explorers = execute query using new management object search (scope, query); // mixed with loop through each drive (Management object drive in finder. Get ()) {// Name & amp; Freespace ("drive", drive ["name"]) to INFO.Add to our hashtable drive; DriveInfo.Add ("Space", Drive ["FreeSpace"]); } INFO return drive; }
Comments
Post a Comment