clwn.net
当前位置:首页 >> vB.nEt 获取目录下文件夹名不包括隐藏文件夹 >>

vB.nEt 获取目录下文件夹名不包括隐藏文件夹

Vb.net获取某个目录下文件夹名称(不包含隐藏文件夹)实现代码如下:Dim dir As New DirectoryInfo("D:\") For Each d As DirectoryInfo In dir.GetDirectories ComboBox1.Items.Add(d.Name) Next dim finfo as new fileinfo(d.name) if (finfo.attributes and FileAttributes.Hidden)<>FileAttributes.Hidden then ComboBox1.Items.Add(d.Name) end if

先用System.IO.Directory.GetDirectories函数获取子目录的名称(包括其路径),再用System.IO.Path.GetFileName获取子目录的名称.下面是代码:Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.

Dim tt As String() = Directory.GetDirectories("C:\") '返回所有的子文件夹 Dim t As String For Each t In tt 这里处理子文件夹 Next

vb.net获取某个目录下文件夹名称(不包含隐藏文件夹)实现代码如下:dim dir as new directoryinfo("d:\") for each d as directoryinfo in dir.getdirectories combobox1.items.add(d.name) nextdim finfo as new fileinfo(d.name) if (finfo.attributes and fileattributes.hidden)fileattributes.hidden then combobox1.items.add(d.name)end if

按照指定的完整路径,循环搜索其中文件夹,搜索到一个,就保存到字符串变量,搜索到新的覆盖该变量,一直到循环结束,输出该变量的值.

Dim WshShell Set WshShell = CreateObject("Wscript.Shell") WshShell.run "cmd.exe /c C:\Windows\dir" Msgbox "成功!", vbOKOnly, "提示"

'窗体上画一个列表框,一个命令按钮.okPrivate Sub command1_click() Dim aa As String Dim bb As String List1.Clear Path = "C:\PROGRAM FILES\" aa = Path bb = Dir(aa, vbDirectory)Do While bb <> "" If sF <> "." And sF <> ".." Then

获取方法,参考实例如下:'获取路径名各部分: 如: c:\dir1001\aaa.txt'获取路径路径 c:\dir1001\ Public Function GetFileName(FilePathFileName As String) As String '获取文件名 aaa.txt On Error Resume Next Dim i As Integer, J As Integer i Len

dim dir as new io.directoryinfo("c:\tddownload")// 目录下就一个文件夹 if dir.getdirectories.length > 0 then messagebox.show(dir.getdirectories.getvalue(0).tostring()) end if// 目录下多个文件夹 'for each d as io.directoryinfo in dir.getdirectories ' messagebox.show(d.fullname) 'next

操作系统要实现文件夹不能直接删除的格式是: 文件名..\操作系统里面,创建一个文件夹后文件夹并非空的,里面还有 . 和 .. 这两个名字的隐藏文件夹来作为是否文件夹的标识,所以CreateDirectory ("d:\\test\\test2.\\") 是创建了test文件夹和test.文件夹,所以你要创建不能直接删除的文件夹,可以改成CreateDirectory ("d:\\test\\test2..\\")

相关文档
网站首页 | 网站地图
All rights reserved Powered by www.clwn.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com