Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, April 24, 2013 9:12 PM
Hi
I have a file in a USB device that I would like to transfer over to my desktop using C#, asp.net code.
Looked at various material but can not understand I need some direction or cose sample to help me going.
Thanks
All replies (3)
Wednesday, April 24, 2013 9:32 PM ✅Answered | 1 vote
The USB is mapped to a physical drive when plugged in by the OS. Once that happens the code as written can acccess any files on a USB by using the standard file IO and requesting the file via its path.
// To copy a file to another location and // overwrite the destination file if it already exists.
System.IO.File.Copy("Path of file on USB", "Path of file on desktop", true);
Ali Hamdar (alihamdar.com - www.ids.com.lb)
Thursday, April 25, 2013 9:30 PM ✅Answered
A USB device can expose multiple interfaces to the OS. The above code works for a USB message storage. You need to clarify the type of device if you want to get files from other kinds of USB devices like scanner, camera, modern Android tablets etc.
Monday, August 11, 2014 4:48 PM
I have this same question, but specifically for a Windows Phone 8 device (or 8.1). These don't seem to be mapped to a drive letter, and rather the path to the device's drive (in Windows Explorer) is something like "This PC\NameOfDevice\Phone\. I don't know of any other way to access the drive directly.
When trying to copy or read files using this type of path, an exception is always thrown (and I assume because it isn't actually a valid path).
So how can we access WP8.x device drives via USB using C#? Is there a special path that can be used?