Drive info

  • 12 years ago
    Here are my code(with help). How can I do the following. 1. How can I show the bytes in this format 123,123,123,123 bytes. 2. How can I use this code to get my servers drive info(I have the user names and passwords for all of them. [CODE] Imports System.IO ' for readig text and get driveinfo Imports System.Net.NetworkInformation 'ip addrsss/ mask eg. Public Class My_Pc 'Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpDirectoryName As String, ByRef lpFreeBytesAvailableToMe As Long, ByRef lpTotalNumberOfBytes As Long, ByRef lpTotalNumberOfFreeBytes As Long) As Integer Private Sub BtnInfo_ClickButtonArea(ByVal Sender As System.Object, ByVal e As System.EventArgs) Handles BtnInfo.ClickButtonArea ' To get host name Dim ipProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties() Dim myProcess As New Process Dim myProcessStartInfo As New ProcessStartInfo("ipconfig", "/all") ' to use text file Dim objStreamWriter As StreamWriter 'Get disk info Dim allDrives() As DriveInfo = DriveInfo.GetDrives() Try Dim d As DriveInfo For Each d In allDrives objStreamWriter = New StreamWriter("C:\Werk\Disk info.txt", True) If d.DriveType.ToString = "Fixed" Then If d.IsReady = True Then objStreamWriter.WriteLine(" ") objStreamWriter.WriteLine(ipProperties.HostName + " " + d.Name.ToString + " " + d.AvailableFreeSpace.ToString + " " + " Bytes free") lstdrives.Items.Add(ipProperties.HostName + " " + d.Name + " " + d.AvailableFreeSpace.ToString + " " + " Bytes free") End If End If 'Close the file. objStreamWriter.Close() Next MsgBox("Write Successful") Catch er As Exception MsgBox(er.Message.ToString, , "Unable to write to file") End Try End Sub End Class [/CODE]

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Linux is only free if your time has no value” - Jamie Zawinski