从USB驱动器获取所有图像 [英] get all the image from a usb drive
本文介绍了从USB驱动器获取所有图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将所有图像从USB驱动器复制到本地文件夹。目前我得到了逻辑驱动器名称。(我的USB驱动器名称是G)。
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).
推荐答案
尝试这样的事情:
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);
}
您可以随时检查USB设备是否已连接 - 用于检测USB设备的USB库 [ ^ ]。
一旦完成,就像读取驱动器一样你会读到任何其他驱动器。
使用目录操作,你可以通读目录结构( http:/ /support.microsoft.com/kb/303974 [ ^ ])并过滤掉图像文件。
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.
这篇关于从USB驱动器获取所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文