c# - 检查目录是否使用 .NET 挂载
问题描述
当我检查目录是否已经挂载时,我想编写代码(并根据答案做一些事情)。
我在 bash 中看到了一些使用类似的解决方案:
if mount | grep /mnt/md0 > /dev/null; then
% Do something
有没有办法在 .NET 中执行相同的过程?或者,检查服务器是否已在 fstab 上注册以进行安装?
谢谢你。
解决方案
你可以像那里一样检查它:
using System.IO;
// and actually checking the directory for the existence
if (Directory.Exists(path))
//Do something
推荐阅读
- c# - 为什么 int 和 string 情况下的结果不同?
- python - 无法在 macOS 上的 Python 3 中使用 tkinter
- javascript - 提供满足 esm、commonjs 和 bundlers 的 module、main 和 browser 字段
- javascript - 单击按钮时如何触发图像弹出(模态/灯箱)
- mysql - Sequelize 在查询中包含多个表
- python-3.x - 我们如何在 python 中使用 selenium 和 webdriver 来获取所有产品名称、价格和评级?假设我们在畅销书的亚马逊页面上
- node.js - Pupateer page.evaluate 解析网站时随机停止工作
- python - 我不明白为什么我的 Port Scanner Python 程序出错
- c# - File.Create c# 中的 System.UnauthorizedAccessException
- php - 记录在 40 秒后显示,有时在查询期间丢失与 MySQL 服务器的连接