首页 > 解决方案 > 检查目录是否使用 .NET 挂载

问题描述

当我检查目录是否已经挂载时,我想编写代码(并根据答案做一些事情)。

我在 bash 中看到了一些使用类似的解决方案:

if mount | grep /mnt/md0 > /dev/null; then % Do something

有没有办法在 .NET 中执行相同的过程?或者,检查服务器是否已在 fstab 上注册以进行安装?

谢谢你。

标签: c#linux.net-core

解决方案


你可以像那里一样检查它:

using System.IO;

// and actually checking the directory for the existence
if (Directory.Exists(path))
  //Do something

推荐阅读