Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0
i need to copy all the images from usb drive to local folder.currently i got the logical drive name.(my usb drive name is G).
Posted 31-Dec-12 22:40pm
Edited 31-Dec-12 22:45pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Try something like this:
string usbRoot = @"H:\";
string destFolder = @"C:\CopiedTo";
string[] files = Directory.GetFiles(usbRoot, "*.jpg", SearchOption.AllDirectories);
foreach (string file in files)
    string dest = destFolder + file.Substring(usbRoot.Length);
    if (!Directory.Exists(Path.GetDirectoryName(dest)))
    File.Copy(file, dest, true);
joshi.ihsoj at 2-Jan-13 4:25am
here in string[] files = Directory.GetFiles(usbRoot, "*.jpg", SearchOption.AllDirectories); i am not getting the files.the project is running mode,still waiting,and no response
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can always check if a USB device is connected - A USB Library to Detect USB Devices[^].
Once this is done, read the drive just like you would read any other drive.
Use directory operations, you can read through the directory structure([^]) and filter out the image files.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
0 Guruprasad.K.Basavaraju 490
1 Sergey Alexandrovich Kryukov 316
2 Shai Vashdi 264
3 OriginalGriff 250
4 praveen_07 115
0 Sergey Alexandrovich Kryukov 9,185
1 OriginalGriff 5,315
2 Peter Leow 4,040
3 Maciej Los 3,535
4 Abhinav S 3,308

Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid