hendrikbez
Active member
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.
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.
VB.NET:
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