Click here to Skip to main content
Rate this: bad
good
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
josh-jw9.5K
Edited 31-Dec-12 22:45pm
v2
Rate this: bad
good
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)))
        {
        Directory.CreateDirectory(Path.GetDirectoryName(dest));
        }
    File.Copy(file, dest, true);
    }
  Permalink  
Comments
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
good
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( http://support.microsoft.com/kb/303974[^]) and filter out the image files.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 368
1 Richard MacCutchan 240
2 OriginalGriff 230
3 Jared Sanow 145
4 Vinay Mistry 133
0 Sergey Alexandrovich Kryukov 5,955
1 OriginalGriff 4,805
2 CPallini 2,473
3 Abhinav S 1,507
4 Richard MacCutchan 1,437


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100