peony3000

Gadgeteer USB Pen Drive 01

Apr 2nd, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System;
  2. using Microsoft.SPOT;
  3. using System.Threading;
  4.  
  5. using GT = Gadgeteer;
  6. using GTM = Gadgeteer.Modules;
  7. using Gadgeteer.Modules.GHIElectronics;
  8.  
  9.  
  10. namespace Gadgeteer_USB_Pen_01
  11. {
  12.     public partial class Program
  13.     {
  14.         void ProgramStarted()
  15.         {
  16.             // Initialize event handling robots
  17.             usbHost.USBDriveConnected += new GTM.GHIElectronics.UsbHost.USBDriveConnectedEventHandler(usb_USBDriveConnected);
  18.             usbHost.USBDriveDisconnected += new GTM.GHIElectronics.UsbHost.USBDriveDisconnectedEventHandler(usb_USBDriveDisconnected);
  19.            
  20.             // create a button watching robot to trigger things when the button is pressed
  21.             button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
  22.         }
  23.  
  24.  
  25.         void button_ButtonPressed(Button sender, Button.ButtonState state)
  26.         {
  27.             throw new NotImplementedException();
  28.         }
  29.        
  30.         void usb_USBDriveDisconnected(GTM.GHIElectronics.UsbHost sender)
  31.         {
  32.             Debug.Print("\r\nThe USB thumb drive has been removed.");
  33.         }
  34.  
  35.         void usb_USBDriveConnected(GTM.GHIElectronics.UsbHost sender, GT.StorageDevice storageDevice)
  36.         {
  37.             Debug.Print("\r\nUSB thumb drive has been inserted.");
  38.             Debug.Print("Using storageDevice from the USBDriveConnected event, the root director is:");
  39.             string[] root = storageDevice.ListRootDirectoryFiles();
  40.             foreach (string fileName in root)
  41.             {
  42.                 Debug.Print("    " + fileName);
  43.             }
  44.             Debug.Print("\r\nPlease remove the USB thumb drive to continue");
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment