This article will show you how you can detect pen drive in windows
using c#.net. In this article I will show you how you can detect all the detail
of a pen drive attached in your machine.
Now put the code as shown below.
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void btnShowDetail_Click(object sender, EventArgs e)
{
var drives = DriveInfo.GetDrives().Where(drive => drive.IsReady
&& drive.DriveType == DriveType.Removable);
if (drives.FirstOrDefault() != null)
{
}
else
{
MessageBox.Show("No Pendrive
found..");
}
}
}
}
|
In above code below mention piece code is responsible for
detecting the pen drive.
var drives = DriveInfo.GetDrives().Where(drive
=> drive.IsReady && drive.DriveType == DriveType.Removable);
|
Now we have done run the application and check the output.
Now try to retest the pen drive without connecting it.
Now connect the pen drive and try to get the detail.
DOWNLOAD
0 comments:
Please let me know your view