Click here to Skip to main content
13,050,617 members (87,264 online)
   

C#

 
GeneralRe: loop through a bindingsource Pin
led mike26-Jul-07 4:55
mvpled mike26-Jul-07 4:55 
QuestionWindow.Opener equivalent Pin
Craigpt18-Jul-07 11:28
memberCraigpt18-Jul-07 11:28 
AnswerRe: Window.Opener equivalent Pin
Guffa18-Jul-07 13:28
mvpGuffa18-Jul-07 13:28 
GeneralRe: Window.Opener equivalent Pin
Craigpt19-Jul-07 4:46
memberCraigpt19-Jul-07 4:46 
AnswerRe: Window.Opener equivalent Pin
Ed.Poore18-Jul-07 13:30
memberEd.Poore18-Jul-07 13:30 
GeneralRe: Window.Opener equivalent Pin
Craigpt19-Jul-07 4:47
memberCraigpt19-Jul-07 4:47 
GeneralRe: Window.Opener equivalent Pin
Ed.Poore19-Jul-07 6:50
memberEd.Poore19-Jul-07 6:50 
Questionmultiline textbox problem Pin
srinivassam17-Jul-07 20:07
membersrinivassam17-Jul-07 20:07 
AnswerRe: multiline textbox problem Pin
Vasudevan Deepak Kumar17-Jul-07 20:10
memberVasudevan Deepak Kumar17-Jul-07 20:10 
QuestionOnComm Events in MSCOMM OCX control Pin
AmarjeetSinghMatharu13-Jul-07 18:38
memberAmarjeetSinghMatharu13-Jul-07 18:38 
AnswerRe: OnComm Events in MSCOMM OCX control Pin
Dave Kreskowiak14-Jul-07 4:00
mvpDave Kreskowiak14-Jul-07 4:00 
QuestionC# USB Detection [modified] Pin
donsolms12-Jul-07 0:43
memberdonsolms12-Jul-07 0:43 
AnswerRe: C# USB Detection Pin
Giorgi Dalakishvili12-Jul-07 1:10
memberGiorgi Dalakishvili12-Jul-07 1:10 
AnswerRe: C# USB Detection Pin
Martin#12-Jul-07 1:38
memberMartin#12-Jul-07 1:38 
Hello,

I'm using System.Management functionality for that!
//Insert
WqlEventQuery q_creation = new WqlEventQuery();
q_creation.EventClassName = "__InstanceCreationEvent";
q_creation.WithinInterval = new TimeSpan(0,0,2);    //How often do you want to check it? 2Sec.
q_creation.Condition = @"TargetInstance ISA 'Win32_DiskDriveToDiskPartition'";
mwe_creation = new ManagementEventWatcher(q_creation);
mwe_creation.EventArrived += new EventArrivedEventHandler(USBEventArrived_Creation);
mwe_creation.Start(); // Start listen for events
 
internal void USBEventArrived_Creation(object sender, EventArrivedEventArgs e) 
{
 
}
 
//Remove
WqlEventQuery q_deletion = new WqlEventQuery();
q_deletion.EventClassName = "__InstanceDeletionEvent";
q_deletion.WithinInterval = new TimeSpan(0,0,2);    //How often do you want to check it? 2Sec.
q_deletion.Condition = @"TargetInstance ISA 'Win32_DiskDriveToDiskPartition'  ";
mwe_deletion = new ManagementEventWatcher(q_deletion);
mwe_deletion.EventArrived += new EventArrivedEventHandler(USBEventArrived_Deletion);
mwe_deletion.Start(); // Start listen for events
 
internal void USBEventArrived_Deletion(object sender, EventArrivedEventArgs e) 
{
 
}


For checking the free and available space:
public void Hashtable GetFreeDriveSpace()
{
	Hashtable drivefreespace = new Hashtable();
	// Get the management class holding Logical Drive information
	ManagementClass mcDriveClass = new ManagementClass("Win32_LogicalDisk");
	// Enumerate all logical drives available
	ManagementObjectCollection mocDrives = mcDriveClass.GetInstances();
	foreach(ManagementObject moDrive in mocDrives)
	{
		/*
		Other values of DriveType property:
		0 Unknown 
		1 No Root Directory 
		2 Removable Disk 
		3 Local Disk 
		4 Network Drive 
		5 Compact Disc 
		6 RAM Disk 
		*/
		try
		{
			//if (int.Parse(moDrive.Properties["DriveType"].Value.ToString()) == 3) //You can check the drive type here
			//{
				// sDeviceId will hold the drive name eg "C:"
				String sDeviceId = moDrive.Properties["DeviceId"].Value.ToString();
				// dSize and dFree will hold the size of the drive and free space in bytes
				double dSize = double.Parse(moDrive.Properties["Size"].Value.ToString());
				double dFree = double.Parse(moDrive.Properties["FreeSpace"].Value.ToString()); //In Byte
			//}
		}
		catch
		{
		}
	}
	mocDrives.Dispose();
	mcDriveClass.Dispose();
}


Hope it helps!

All the best,

Martin

GeneralRe: C# USB Detection Pin
donsolms12-Jul-07 1:54
memberdonsolms12-Jul-07 1:54 
QuestionGetting Processsor ID without ManagementClass Pin
MrEyes27-Jun-07 3:58
memberMrEyes27-Jun-07 3:58 
AnswerRe: Getting Processsor ID without ManagementClass Pin
Luc Pattyn27-Jun-07 7:17
memberLuc Pattyn27-Jun-07 7:17 
QuestionImplicit/Explicit variable initialization & performance [modified] Pin
KiTsuNeKo20-Jun-07 15:42
memberKiTsuNeKo20-Jun-07 15:42 
AnswerRe: Implicit/Explicit variable initialization & performance Pin
Christian Graus20-Jun-07 15:47
staffChristian Graus20-Jun-07 15:47 
GeneralRe: Implicit/Explicit variable initialization & performance Pin
KiTsuNeKo20-Jun-07 15:51
memberKiTsuNeKo20-Jun-07 15:51 
GeneralRe: Implicit/Explicit variable initialization & performance Pin
Christian Graus20-Jun-07 16:26
staffChristian Graus20-Jun-07 16:26 
GeneralRe: Implicit/Explicit variable initialization & performance Pin
KiTsuNeKo20-Jun-07 16:29
memberKiTsuNeKo20-Jun-07 16:29 
GeneralRe: Implicit/Explicit variable initialization & performance Pin
Luc Pattyn21-Jun-07 0:22
memberLuc Pattyn21-Jun-07 0:22 
Questionbrainbench test with no answer? Pin
brsecu7-Jun-07 10:14
memberbrsecu7-Jun-07 10:14 
AnswerRe: brainbench test with no answer? Pin
Luc Pattyn7-Jun-07 12:45
memberLuc Pattyn7-Jun-07 12:45 
AnswerRe: brainbench test with no answer? Pin
Vrungar6-Apr-11 9:04
memberVrungar6-Apr-11 9:04 
AnswerRe: brainbench test with no answer? Pin
Luc Pattyn6-Apr-11 13:46
mvpLuc Pattyn6-Apr-11 13:46 
Question"Loading of the ImageList did not succeed" error Pin
Mertli Ozgur Nevres4-Jun-07 21:44
memberMertli Ozgur Nevres4-Jun-07 21:44 
AnswerRe: "Loading of the ImageList did not succeed" error Pin
Luc Pattyn5-Jun-07 0:45
memberLuc Pattyn5-Jun-07 0:45 
GeneralRe: "Loading of the ImageList did not succeed" error Pin
Mertli Ozgur Nevres5-Jun-07 1:13
memberMertli Ozgur Nevres5-Jun-07 1:13 
AnswerRe: "Loading of the ImageList did not succeed" error Pin
Hesham yassin6-Jun-07 8:20
memberHesham yassin6-Jun-07 8:20 
QuestionGive Access to Certificate in Store Pin
mikker_12331-May-07 13:02
membermikker_12331-May-07 13:02 
AnswerRe: Give Access to Certificate in Store Pin
blackjack215031-May-07 23:55
memberblackjack215031-May-07 23:55 
GeneralRe: Give Access to Certificate in Store Pin
mikker_1231-Jun-07 0:23
membermikker_1231-Jun-07 0:23 
GeneralRe: Give Access to Certificate in Store Pin
DotNet_Naeem2-Sep-09 13:49
memberDotNet_Naeem2-Sep-09 13:49 
QuestionUsing GetMessage in C# Pin
gapfulgence31-May-07 2:46
membergapfulgence31-May-07 2:46 
AnswerRe: Using GetMessage in C# Pin
kubben31-May-07 3:00
memberkubben31-May-07 3:00 
GeneralRe: Using GetMessage in C# Pin
gapfulgence31-May-07 4:19
membergapfulgence31-May-07 4:19 
GeneralRe: Using GetMessage in C# Pin
kubben31-May-07 4:22
memberkubben31-May-07 4:22 
GeneralRe: Using GetMessage in C# Pin
gapfulgence31-May-07 6:11
membergapfulgence31-May-07 6:11 
GeneralRe: Using GetMessage in C# Pin
baranils4-Jan-11 9:00
memberbaranils4-Jan-11 9:00 
GeneralRe: Using GetMessage in C# Pin
kubben4-Jan-11 13:12
memberkubben4-Jan-11 13:12 
GeneralRe: Using GetMessage in C# Pin
baranils4-Jan-11 19:41
memberbaranils4-Jan-11 19:41 
GeneralRe: Using GetMessage in C# Pin
kubben5-Jan-11 1:56
memberkubben5-Jan-11 1:56 
GeneralRe: Using GetMessage in C# Pin
baranils5-Jan-11 2:23
memberbaranils5-Jan-11 2:23 
GeneralRe: Using GetMessage in C# Pin
kubben5-Jan-11 2:42
memberkubben5-Jan-11 2:42 
GeneralRe: Using GetMessage in C# Pin
baranils5-Jan-11 3:44
memberbaranils5-Jan-11 3:44 
Questioncan we add a vertical scroll bar in MessageBox.Show( )option?? Pin
prateek_nitw27-May-07 21:31
memberprateek_nitw27-May-07 21:31 
AnswerRe: can we add a vertical scroll bar in MessageBox.Show( )option?? Pin
Muammar©27-May-07 22:11
memberMuammar©27-May-07 22:11 
GeneralRe: can we add a vertical scroll bar in MessageBox.Show( )option?? Pin
prateek_nitw27-May-07 22:37
memberprateek_nitw27-May-07 22:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 25 Jul 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid