#regionUSB Stick Monitor Public Const intWm_devicechange =0x219; Public Const intDbt_devicearrival =0x8000; Public Const intDbt_deviceremovecomplete =0x8004; stringDRIVESTR;//Drive name protected Override voidWndProc (refMessage m) { if(M.msg = =wm_devicechange) { Switch(M.wparam.toint32 ()) { CaseWm_devicechange: Break; CaseDbt_devicearrival://USB Insert{driveinfo[] s=driveinfo.getdrives (); foreach(DriveInfo Driveinchs) {if(Drive. DriveType = =drivetype.removable) {drivestr=Drive . Name; Netconnect (); } } Break; } CaseDbt_deviceremovecomplete://USB stick Pull out{netconnect (); Break; } } } Base. WndProc (refm); } #endregion
#regionGet a picture or video list Public stringgetvideofilelist () {stringFileList =""; Driveinfo[] Drives=driveinfo.getdrives (); foreach(DriveInfo Driveinchdrives) { //if (drive. DriveType = = drivetype.removable)//{ stringDrivestr =Drive . Name; if(Directory.Exists (drivestr)) {foreach(stringDinchdirectory.getfilesystementries (DRIVESTR)) { if(D.equals (Drivestr +"Weixinmp4")) { foreach(stringM_fileinchDirectory.getfilesystementries (d)) { if(M_file. EndsWith (". mp4") || M_file. EndsWith (". flv") ) {fileList+="file:///"+ M_file +"|"; } } } Else { } } if(Filelist.length >0) {fileList= Filelist.substring (0, Filelist.length-1); } } //} } returnfileList; } #endregion
USB Stick Monitor