如何在不知道特定目录名称的情况下检查是否存在任何目录,而只知道该文件夹可能位于的文件夹
在 vb.net 中,如何检查目录中是否存在任何目录
我需要知道 c:\windows 目录中是否存在文件夹(不知道其中是否存在任何目录)。
In vb.net how do you check if a ANY directory exists inside a directory
I would need to know if there is a folder inside the c:\windows directory (WITHOUT knowing if there is ANY directory is in there).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
那么你想检查一个目录中是否有子目录?很公平:
So you want to check to see if there are subdirectories in a directory? Fair enough:
您可以在 System.IO 命名空间内使用 DirectoryInfo 类。
例子:
You can use the DirectoryInfo class inside the System.IO namespace.
Example:
与使用 mattbasta 建议的 VB 特定函数不同,使用 System.IO.Directory 类也同样简单,该类是 BCL 的一部分,任何其他 .NET 开发人员都会熟悉该类。
Rather than use a VB-specific function like mattbasta suggests, it's just as easy to use the
System.IO.Directory
class, which is part of the BCL and would be familiar to any other .NET developer.问题是我无法转换为字符串
'课程是一个对象,而lessonName是字符串类型的属性。如何将目录信息转换为字符串?
Problem is that i cant convert to string
'the the lesson is an object, and lessonName is the property of type string. How do i convert the directoryInfo to string?