Im trying to get hard drive info and output it using Textbox.ReflectMessage. any idea how to do this
this is my code:
using System;
using
System.Collections.Generic;using
System.ComponentModel;using
System.Data;using
System.Drawing;using
System.Linq;using
System.Text;using
System.Windows.Forms;using
System.IO;namespace
procCount{
public partial class Form1 : Form{
public Form1(){
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e){
DriveInfo[] allDrives = DriveInfo.GetDrives(); foreach (DriveInfo c in allDrives){
TextBox.ReflectMessage = "Drive {0}" + c.Name; TextBox.ReflectMessage = " File type: {0}" + c.DriveType; if (c.IsReady == true){
TextBox.ReflectMessage = " Volume label: {0}" + c.VolumeLabel; TextBox.ReflectMessage = " File system: {0}" + c.DriveFormat; TextBox.ReflectMessage = " Available space to current user: {0, 100} bytes" + c.AvailableFreeSpace; TextBox.ReflectMessage = " Total available space: {0, 100} bytes" + c.TotalFreeSpace; TextBox.ReflectMessage = " Total size of drive: {0, 100} bytes" + c.TotalSize;}
}
}
}
}
the out put i get is:
File type: {0}CDRom
and its in a text box just now showing me the info ....
thank you for your time.
RyanPosted Dec 28, 2008, 11:14 PM
I will keep that in mind. Thank you again for your help on that.
Ryan AlfordPosted Dec 28, 2008, 12:21 PM
RyanPosted Dec 27, 2008, 10:31 PM
Ryan AlfordPosted Dec 27, 2008, 10:24 PM
I used a richtextbox since it's easier to display multi-line text.
private void Form1_Load(object sender, EventArgs e)
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
StringBuilder sb = new StringBuilder();
foreach (DriveInfo c in allDrives)
{
sb.AppendLine(string.Format("Drive {0}", c.Name));
sb.AppendLine(string.Format("File type: {0}", c.DriveType));
if (c.IsReady)
{
sb.AppendLine(string.Format("Volume label: {0}", c.VolumeLabel));
sb.AppendLine(string.Format("File System: {0}", c.DriveFormat));
sb.AppendLine(string.Format("Available space to current user: {0}", c.AvailableFreeSpace));
sb.AppendLine(string.Format("Total available space: {0}", c.TotalFreeSpace));
sb.AppendLine(string.Format("Total size of drive: {0}", c.TotalSize));
}
}
richTextBox1.Text = sb.ToString();
}