PDA

View Full Version : انتقال از فایل فلش



myysl97
یک شنبه 15 تیر 1393, 16: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'."}
چطور کد بنویسم؟که فایل ها رو نشون بده

Amiri.projects
یک شنبه 15 تیر 1393, 23:42 عصر
;()listBox1.Items.Clear
;(() DriveInfo drinfo = new DriveInfo(comboBox1.SelectedItem.ToString
(if (comboBox1.SelectedIndex != -1

}

((foreach (var item in Directory.GetFiles((drinfo).Name

}

;( listBox1.Items.Add(item

{
{

نمیتونست String رو به نوع DriveInfo ، تبدیل (Cast) کنه . موفق باشید