Click here to Skip to main content
12,450,089 members (42,540 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# 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-jw16.1K
Updated 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2016
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