myysl97
یک شنبه 15 تیر 1393, 17:13 عصر
سلام دوستان من یو اس بی رو نشون میدم در لیست باکس
حالا یه دگمه گذاشتم که اگر رو اون کلیک بشه لیست فایل های داخل یو اس بی نشون داده بشه
که من این کد رو نوشتم ولی
listBox1.Items.Clear();
if (comboBox1.SelectedIndex != -1)
{
foreach (var item in Directory.GetFiles(((DriveInfo)comboBox1.SelectedI tem).Name))
{
listBox1.Items.Add(item);
}
}
ارور میده
{"Unable to cast object of type 'System.String' to type 'System.IO.DriveInfo'."}
چطور کد بنویسم؟که فایل ها رو نشون بده
حالا یه دگمه گذاشتم که اگر رو اون کلیک بشه لیست فایل های داخل یو اس بی نشون داده بشه
که من این کد رو نوشتم ولی
listBox1.Items.Clear();
if (comboBox1.SelectedIndex != -1)
{
foreach (var item in Directory.GetFiles(((DriveInfo)comboBox1.SelectedI tem).Name))
{
listBox1.Items.Add(item);
}
}
ارور میده
{"Unable to cast object of type 'System.String' to type 'System.IO.DriveInfo'."}
چطور کد بنویسم؟که فایل ها رو نشون بده