• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Trying to develop a program to transfer files to USB when plugged in - how?

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

syypher

Member
Joined
Oct 8, 2009
I'm completely ignorant to programming and have been given the task to develop/find assistance to develop a program that does the following.

Goal: Mini Computer with 4x USB ports needs to transfer files (small video files and mp3s) to a specific USB port when plugged in. 2x of the USB ports will be designated to transfer out Video files when a flashdrive is plugged in. The other 2x USB ports will be designated to transfer out anMP3 file when a flashdrive is plugged in. This is going to be consumers use so the easier the steps they have to take the better.

Parameters:

-Each USB port will be uniquely named. Ex. If flashdrive is plugged into USBPort1 or USBPort2, MP3 will be transferred. If flashdrive is plugged into USBPort3 or USBPort4, Video file will be transferred.

-Should be able to handle plugging in multiple flashdrives at a time. If flashdrives are plugged into all ports at the same time, the appropriate file will be transferred to the designated port.

-USB Ports should be listening for a device to be plugged in.

-Check USB flashdrive for space. Will the Video or MP3 file fit?

-If Yes, copy the latest file in C:\X-directory to flashdrive

-If No, either (optional- notify user not enough space) or eject device and go back to listening for new USB device to be plugged in

(Optional) - Notification of when file is finished transferring to flashdrive, if flashdrive is too full, or generic error from failure (Maybe by LED? to Monitor?)


Does anyone know how I can do this? Or where I can find help to create a program like this? Or is there a hardware device that I could use that would make this work? I've never had to find help to create a program before and this is a very niche project. To my knowledge there are no programs that match our needs available right now.
 
Last edited:
I don't have time to help you out 100%, but I can tell you that using an autorun.inf on the USB drive can get you to autotransfer files when you plug the device in. Going that route though, you wouldn't be able to differentiate between what USB port would be plugged in. You might be able to do that with Microsoft's SyncToy, but I have no experience with it.
 
I think what he's probably after is having the PC handle the logic of which ports have a drive attached, and what to copy... rather than having the information on the flash drive itself.


You'll need to break our problem out into smaller tasks to start making progress. I'd start with a language like Powershell. It's extremely robust and pretty easy to pick up and find help for. Your first few steps might be figuring out how to List USB ports or List USB devices attached. After that, you'd need to figure out how to check which port a device is plugged into.. and then check if it is writable, make sure it's not some other USB device like a keyboard, make sure it has space, etc.

All very doable, but you're right that it's a niche project that you probably won't find some code you can copy/paste to make it work. You'll have to get creative, and probably learn quite a bit along the way. Sounds fun, though!
 
I've written something like this before in C#, and off the top of my head, I think there was a timer that periodically checked for USB devices. That, or there's an event you can listen for, it was a few years ago.

I think the easiest approach would be a Windows service with a config file to handle the file transfer rules.

This is a relatively simple application, I could probably bang it out in like an hour.
 
Back