Tag: 可移动

C#如何知道可移动磁盘是USB驱动器还是SD卡?

Windows 7平台,C# 我使用以下语句列出所有驱动器: DriveInfo[] drives = DriveInfo.GetDrives(); 然后我可以使用DriveType找出所有可移动磁盘: foreach (var drive in drives) { if(drive.DriveType == DriveType.Removable) yield return drive; } 现在我的问题是,SD卡磁盘和USB闪存盘共享相同的driveType:可移动,那么我怎么才能找到USB闪存盘? 谢谢!

通过在C#中使用鼠标拖动控件来移动控件

我试图通过拖动它来移动名为pictureBox1的控件。 问题是,当它移动时,它会一直从一个位置移动到鼠标周围的另一个位置,但它确实跟着它…这是我的代码。 如果你能帮助我,我真的很感激 public partial class Form1 : Form { public Form1() { InitializeComponent(); } bool selected = false; private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { selected = true; } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (selected == true) { pictureBox1.Location = e.Location; } } private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { selected […]