gpt4 book ai didi

c# - 检测路径是否指向 NTFS 分区

转载 作者:可可西里 更新时间:2023-11-01 11:20:32 25 4
gpt4 key购买 nike

给定绝对文件系统路径,我如何检测它是否在 NTFS 分区上?我更喜欢 C# 的帮助,但 Win32/C 会做。软件运行的系统为Windows Vista或更高版本。

最佳答案

//Get all the drives on the local machine.
DriveInfo[] allDrives = DriveInfo.GetDrives();

//Get the path root.
var pathRoot = Path.GetPathRoot(absoluteFilePath);
//Find the drive based on the path root.
var driveBasedOnPath = allDrives.FirstOrDefault(d => d.RootDirectory.Name == pathRoot);
//Determine if NTFS
var isNTFS = driveBasedOnPath != null ? driveBasedOnPath.DriveFormat == "NTFS" : false;

关于c# - 检测路径是否指向 NTFS 分区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12867196/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com