Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我到处寻找,但没有找到适合我所追求的东西。
我正在为我的 LED 灯制作一个实用程序。我需要将一个名为 hy.txt 的文本文件保存到我的 SD 卡上。显然,根据您插入的驱动器号,每次都会更改。所以我将我的 SD 卡重命名为 STAR-LIGHT。
我不知道如何搜索名称,但是,我只看到有人在寻找驱动器号。
我不确定这是否有意义。请随时问我任何问题。
这个“可能”有效(仅尝试使用 USB 驱动器和我的硬盘分区):
string[] drives = Environment.GetLogicalDrives(); foreach (string drive in drives) { try { DriveInfo di = new DriveInfo(drive); if (di.VolumeLabel == "STAR-LIGHT") { // code } } catch { // ... } }