在 nodejs 中枚举系统驱动器 [英] Enumerate system drives in nodejs
本文介绍了在 nodejs 中枚举系统驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法检索计算机上所有逻辑驱动器的驱动器名称?
我看过 fs api,但从那里我只能枚举给定目录的文件和目录.
解决方案
我不确定您所说的驱动器名称"是什么意思.如果您指的是 \\.\PhysicalDriveN
形式的驱动器,我遇到了同样的问题并实现了这个适用于所有主要操作系统的模块:
https://github.com/resin-io/drivelist
对于 Windows,您会获得如下信息:
<预><代码>[{设备:'\\\\.\\PHYSICALDRIVE0',描述:'WDC WD10JPVX-75JC3T0',大小:'1000 GB'},{设备:'\\\\.\\PHYSICALDRIVE1',描述:通用存储设备 USB 设备",大小:'15 GB'}]Is there a way to retrieve the drive name of all logical drives on a computer ?
I've looked at the fs api, but from there I can only enumerate the files and directories of a given directory.
解决方案
I'm not sure what you mean by "drive name". If you mean drives in the form of \\.\PhysicalDriveN
, I faced the same problem and implemented this module that works in all major operating systems:
https://github.com/resin-io/drivelist
For Windows, you get information such as:
[
{
device: '\\\\.\\PHYSICALDRIVE0',
description: 'WDC WD10JPVX-75JC3T0',
size: '1000 GB'
},
{
device: '\\\\.\\PHYSICALDRIVE1',
description: 'Generic STORAGE DEVICE USB Device',
size: '15 GB'
}
]
这篇关于在 nodejs 中枚举系统驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文