c# - 确定文件在哪个物理硬盘上?

标签 c# file disk

如何找到文件/目录所在的物理驱动器。我想比较 2 个文件,如果它们位于两个不同的驱动器上,那么我可以通过同时读取两个文件来加快比较速度。

问候

最佳答案

这可能需要 P/Invoke。

Way to know if two partitions are in one physical hard disk without WMI?

来自上面的链接:

The Win32 function you'll need is called DeviceIoControl(). The API documentation can be found at http://msdn.microsoft.com/en-us/library/aa363216(VS.85).aspx. Call DeviceIoControl() with the control code IOCTL_STORAGE_GET_DEVICE_NUMBER and you'll get the physical disk drive for the given partition device handle. The device handle for the partition can be retrieved using CreateFile() API.

关于c# - 确定文件在哪个物理硬盘上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5207641/

相关文章:

c# - C#UDP监听器线程—是否不使用while(true)刻录CPU?

c# - 使窗体的背景透明

file - 如何查看 db2 表(文件)的模式

c# - 使用 CanExecute 参数调用 RelayCommand<T>

c# - ASP.NET MVC2 : IQueryable from join

java - 在java中同时读取和写入文件

python - 如何将字典存储在文件中并读取/写入该文件?

c# - 如何正确地将以字节为单位的文件大小转换为兆字节或千兆字节?

bash - 如何根据磁盘ID获取磁盘名称?

cpanel - 磁盘空间被 `vda`文件占满,如何清除?