|
Answer» I admit defeat!
I am using Visual Basic 2008 - and after around 4-5 hours of searching every nook and cranny of the net I cannot for the life of me FIND the right solution.
I want to display the available space of a hard drive in a text box. Simple!
I have lots of code (mostly VB6 - I'm asking myself why I went with 2008), such as this taken from VB 2008 help online:
IMPORTS System Imports System.IO
Class Test Public Shared Sub Main() Dim allDrives() As DriveInfo = DriveInfo.GetDrives()
Dim d As DriveInfo For Each d In allDrives Console.WriteLine("Drive {0}", d.Name) Console.WriteLine(" File type: {0}", d.DriveType) If d.IsReady = True Then Console.WriteLine(" Volume label: {0}", d.VolumeLabel) Console.WriteLine(" File system: {0}", d.DriveFormat) Console.WriteLine( _ " Available space to current user:{0, 15} bytes", _ d.AvailableFreeSpace)
Console.WriteLine( _ " Total available space: {0, 15} bytes", _ d.TotalFreeSpace)
Console.WriteLine( _ " Total size of drive: {0, 15} bytes ", _ d.TotalSize) End If Next End Sub End Class
And i get.....nothing!!
I have vbscript that performs perfectly well, but visual basic won't run the vbscript file (this is why I use a Mac!!). I
I'd like this function to run as SOON as the form loads.... well actually I'd like a bottle of wine and a night out, but HEY ho!
Anybody, somebody.... lend me your ears. Quote I want to display the available space of a hard drive in a text box. Simple!
Where is the text box? You can't use console.write to a text box. And you can't have a TEXTBOX in a console application.
You code produces output on the console with no problems. (VS2005)Quote from: Sidewinder on November 04, 2008, 02:21:03 PMWhere is the text box? You can't use console.write to a text box. And you can't have a textbox in a console application. The code I had was what M$ offered in their help section - I was trying to submit the response to a text box but wasn't sure how to accomplish this.
Since found:
Dim driveSpace As String driveSpace = (New DriveInfo("C").AvailableFreeSpace / 1024 / 1024) TextBox.Text = driveSpace
All done!
|