Click here to Skip to main content
12,450,848 members (44,634 online)
   

C#

 
JokeRe: The magic of TransactionScope Pin
Luc Pattyn12-Jul-07 1:53
memberLuc Pattyn12-Jul-07 1:53 
JokeRe: The magic of TransactionScope Pin
Le Centriste12-Jul-07 1:54
memberLe Centriste12-Jul-07 1:54 
GeneralRe: The magic of TransactionScope Pin
Martin#12-Jul-07 1:59
memberMartin#12-Jul-07 1:59 
AnswerRe: The magic of TransactionScope Pin
Christian Graus12-Jul-07 2:41
staffChristian Graus12-Jul-07 2:41 
GeneralRe: The magic of TransactionScope Pin
Martin#12-Jul-07 2:47
memberMartin#12-Jul-07 2:47 
GeneralRe: The magic of TransactionScope Pin
Le Centriste12-Jul-07 2:51
memberLe Centriste12-Jul-07 2:51 
AnswerRe: The magic of TransactionScope Pin
Pete O'Hanlon12-Jul-07 2:49
memberPete O'Hanlon12-Jul-07 2:49 
GeneralRe: The magic of TransactionScope Pin
Le Centriste12-Jul-07 2:53
memberLe Centriste12-Jul-07 2:53 
AnswerRe: The magic of TransactionScope Pin
Judah Himango12-Jul-07 5:05
memberJudah Himango12-Jul-07 5:05 
Questionhow to close child form on the click event of toolstrip button Pin
monuSaini12-Jul-07 0:44
membermonuSaini12-Jul-07 0:44 
AnswerRe: how to close child form on the click event of toolstrip button Pin
Bekjong12-Jul-07 2:04
memberBekjong12-Jul-07 2:04 
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 
QuestionHow to convert CSV file to XLS file using C# Programme Pin
liyakhat_shahid12-Jul-07 0:27
memberliyakhat_shahid12-Jul-07 0:27 
AnswerRe: How to convert CSV file to XLS file using C# Programme Pin
Bijesh12-Jul-07 1:06
memberBijesh12-Jul-07 1:06 
GeneralRe: How to convert CSV file to XLS file using C# Programme Pin
liyakhat_shahid13-Jul-07 1:55
memberliyakhat_shahid13-Jul-07 1:55 
AnswerRe: How to convert CSV file to XLS file using C# Programme Pin
Jimmanuel12-Jul-07 1:15
memberJimmanuel12-Jul-07 1:15 
AnswerRe: How to convert CSV file to XLS file using C# Programme Pin
martin_hughes12-Jul-07 2:30
membermartin_hughes12-Jul-07 2:30 
AnswerRe: How to convert CSV file to XLS file using C# Programme Pin
Pete O'Hanlon12-Jul-07 3:03
memberPete O'Hanlon12-Jul-07 3:03 
QuestionProblem with Cookies Enabled detection Pin
Adoremi11-Jul-07 23:10
memberAdoremi11-Jul-07 23:10 
AnswerRe: Problem with Cookies Enabled detection Pin
chandu_shar12-Jul-07 0:21
memberchandu_shar12-Jul-07 0:21 
Questiondisable all DataGridViewRowHeaderCell glyphs Pin
agent32711-Jul-07 22:37
memberagent32711-Jul-07 22:37 
QuestionProblems with configuring .Net hosted control Pin
Cuchuk Sergey11-Jul-07 22:24
memberCuchuk Sergey11-Jul-07 22:24 
Questionradiobutton BeforeStateChange ? Pin
fracalifa11-Jul-07 22:20
memberfracalifa11-Jul-07 22:20 
AnswerRe: radiobutton BeforeStateChange ? Pin
Martin#11-Jul-07 22:32
memberMartin#11-Jul-07 22:32 
AnswerRe: radiobutton BeforeStateChange ? Pin
Luc Pattyn11-Jul-07 23:48
memberLuc Pattyn11-Jul-07 23:48 
GeneralRe: radiobutton BeforeStateChange ? Pin
Martin#12-Jul-07 0:05
memberMartin#12-Jul-07 0:05 
GeneralRe: radiobutton BeforeStateChange ? [modified] Pin
fracalifa12-Jul-07 0:32
memberfracalifa12-Jul-07 0:32 
GeneralRe: radiobutton BeforeStateChange ? Pin
Luc Pattyn12-Jul-07 0:36
memberLuc Pattyn12-Jul-07 0:36 
GeneralRe: radiobutton BeforeStateChange ? Pin
fracalifa12-Jul-07 0:40
memberfracalifa12-Jul-07 0:40 
JokeRe: radiobutton BeforeStateChange ? Pin
Luc Pattyn12-Jul-07 1:44
memberLuc Pattyn12-Jul-07 1:44 
AnswerRe: radiobutton BeforeStateChange ? Pin
ruanr12-Jul-07 0:23
memberruanr12-Jul-07 0:23 
AnswerRe: radiobutton BeforeStateChange ? Pin
Martin#12-Jul-07 0:39
memberMartin#12-Jul-07 0:39 
GeneralRe: radiobutton BeforeStateChange ? Pin
fracalifa12-Jul-07 1:07
memberfracalifa12-Jul-07 1:07 
GeneralRe: radiobutton BeforeStateChange ? Pin
Martin#12-Jul-07 1:11
memberMartin#12-Jul-07 1:11 
GeneralRe: radiobutton BeforeStateChange ? Pin
fracalifa12-Jul-07 1:18
memberfracalifa12-Jul-07 1:18 
GeneralRe: radiobutton BeforeStateChange ? Pin
Martin#12-Jul-07 1:40
memberMartin#12-Jul-07 1:40 
Questioncreating a custom editor Pin
kuda_crystaltouch11-Jul-07 21:38
memberkuda_crystaltouch11-Jul-07 21:38 
AnswerRe: creating a custom editor Pin
Bekjong12-Jul-07 0:03
memberBekjong12-Jul-07 0:03 
GeneralRe: creating a custom editor Pin
kuda_crystaltouch12-Jul-07 1:52
memberkuda_crystaltouch12-Jul-07 1:52 
GeneralRe: creating a custom editor Pin
Bekjong12-Jul-07 1:59
memberBekjong12-Jul-07 1:59 
GeneralRe: creating a custom editor Pin
kuda_crystaltouch12-Jul-07 2:13
memberkuda_crystaltouch12-Jul-07 2:13 
QuestionProblem with Timer object Pin
alashara11-Jul-07 21:22
memberalashara11-Jul-07 21:22 
AnswerRe: Problem with Timer object Pin
Martin#11-Jul-07 21:32
memberMartin#11-Jul-07 21:32 
GeneralRe: Problem with Timer object Pin
alashara11-Jul-07 23:13
memberalashara11-Jul-07 23:13 
GeneralRe: Problem with Timer object [modified] Pin
Martin#11-Jul-07 23:28
memberMartin#11-Jul-07 23:28 
GeneralRe: Problem with Timer object Pin
Luc Pattyn11-Jul-07 23:54
memberLuc Pattyn11-Jul-07 23:54 
QuestionDate time format Pin
MarkBrock11-Jul-07 21:11
memberMarkBrock11-Jul-07 21:11 

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.160826.1 | Last Updated 27 Aug 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid