removable-drive

Detect removable drive (e.g. USB flash drive) C/C++

↘锁芯ラ 提交于 2020-01-12 07:39:07
问题 How can I detect when a removable disk drive is (dis)connected to the system? How to get the mount path (for Linux) and the drive letter (for windows)? EDIT: Is there a way to detect the currently connected devices? 回答1: For Windows, the API RegisterDeviceNotification will let you know when a USB device is added. The information about the volume is given in the DEV_BROADCAST_VOLUME structure. The dbcv_unitmask gives the drive letter. 回答2: You can get the change notifications (for drive added

how to access mobile device (windows mobile 6.0 or higher) drive using C# in Winforms

两盒软妹~` 提交于 2020-01-06 05:39:14
问题 I would like to transfer a file from developer computer to mobile device which is a handheld terminal. Also, I have an SD card which can be used as removable device. When I plugged in that SD Card into PC's slot, it's used as removable device and easily I can copy any file into SD Card using C# DriveInfo class. But, when I plugged in the handheld terminal with USB cable to PC, I would like to reach folders and files in mobile device and want to do same things like copying and deleting any

Searching for SD-cards

强颜欢笑 提交于 2020-01-01 12:18:28
问题 I need to implement searching for SD-cards in my program. Currently I'm using search for all removable devices like: searcher = New Management.ManagementObjectSearcher("\\localhost\root\cimv2", "SELECT DeviceId FROM Win32_LogicalDisk WHERE DriveType=2 AND Size>0"); But it find USB flash drives also. Is there a proper way to find SD-cards only? What I need is in general only drive letter for available SD-cards (like "F:" or so). 回答1: The SD cards use to have an unique ID. USB memories not. So

How to retrieve removable storage drive letter using C/C++ [duplicate]

蹲街弑〆低调 提交于 2019-12-24 12:52:44
问题 This question already has answers here : Enumerating all available drive letters in Windows (6 answers) Closed 4 years ago . How can I get the removable drive letter so that I could create a path and copy data from PC to the removable drive? Currently I'm using _getcwd(buff,b_SIZE); MessageBox(buff); strncpy(Root,buff,3); I have no problem if I run my software directly from the USB and it will returns to me either D: or E:, which depends on the availability I guess. But my problem is I have

GetDriveType in C#? or find out if my drive is removable?

廉价感情. 提交于 2019-12-17 21:04:13
问题 I am using Environment.GetLogicalDrives(); to get a list of drives. I remember in c++ i could use GetDriveType to find if the device was CD, removable, flash, etc and i am thinking i want to put a filter in my app to only show CD and removable on default. What is the GetDriveType equivalent in C#? google only showed me hacks to use the c++ call. 回答1: Yes, the framework includes a DriveType enumeration used by the DriveInfo class. Have a look at the GetDrives() method on MSDN. 回答2: DriveInfo

How to turn off encrypting of .sln files in Visual Studio on removable drive?

青春壹個敷衍的年華 提交于 2019-12-13 19:20:37
问题 Problem description: (occurs at least in VS2005 and VS2008, not tested in VS 2010) If project (e.g. .csproj) or solution file (.sln) is opened from removable drive, and something happens ... seems like if drive is disconnected without safe removing, or if computer crashes or if VS crashes, then project and/or solution files got encrypted. It seems like Visual Studio encrypts project files when opened and only decrypts them when Visual Studio or project is correctly closed. If something

Detect Removable Media Ejection Request in Windows Service

女生的网名这么多〃 提交于 2019-12-11 00:46:06
问题 I have a Windows service written in C# with the .NET 2.0 framework that uses the FileSystemWatcher to monitor certain directories for changes. Some of these directories may be on removable media, such as a USB drive. When a new drive is plugged into the system, I get notification through a WMI query and can set up a new FileSystemWatcher. All that works well. The difficulty is that I want the user to be able to eject the drive using the Windows "Safely Remove Hardware" app, but Windows

Detecting Removable drive letter in CMD

别说谁变了你拦得住时间么 提交于 2019-12-08 02:55:32
问题 I'm trying to write a script, which will detect the letter of my USB Removable Drive called "UUI" and then create folder on it. I've written few commands for CMD which, when run separately, work. However when I put them into a bat file, I always get some errors. Here are the commands in a bat file: for /F "tokens=1 delims= " %i in ('WMIC logicaldisk where "DriveType=2" list brief ^| c:\windows\system32\find.exe "UUI"') do (echo %i > drive.txt) set /p RemovableDriveLetter2= < drive.txt del /F

Detecting Removable drive letter in CMD

僤鯓⒐⒋嵵緔 提交于 2019-12-06 13:52:08
I'm trying to write a script, which will detect the letter of my USB Removable Drive called "UUI" and then create folder on it. I've written few commands for CMD which, when run separately, work. However when I put them into a bat file, I always get some errors. Here are the commands in a bat file: for /F "tokens=1 delims= " %i in ('WMIC logicaldisk where "DriveType=2" list brief ^| c:\windows\system32\find.exe "UUI"') do (echo %i > drive.txt) set /p RemovableDriveLetter2= < drive.txt del /F /Q drive.txt set RemovableDriveLetter=%RemovableDriveLetter2:~0,1% %RemovableDriveLetter%: md

Searching for SD-cards

十年热恋 提交于 2019-12-04 10:17:53
I need to implement searching for SD-cards in my program. Currently I'm using search for all removable devices like: searcher = New Management.ManagementObjectSearcher("\\localhost\root\cimv2", "SELECT DeviceId FROM Win32_LogicalDisk WHERE DriveType=2 AND Size>0"); But it find USB flash drives also. Is there a proper way to find SD-cards only? What I need is in general only drive letter for available SD-cards (like "F:" or so). The SD cards use to have an unique ID. USB memories not. So you can use that to distinguish from USB and the SD card. I have used it in windows ce and was working