先用System.IO.Directory.GetDirectories函數(shù)獲取子目錄的名稱(包括其路徑),再用System.IO.Path.GetFileName獲取子目錄的名稱。下面是代碼:
在青田等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè) 網(wǎng)站設(shè)計(jì)制作按需設(shè)計(jì),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站設(shè)計(jì),成都營(yíng)銷網(wǎng)站建設(shè),成都外貿(mào)網(wǎng)站制作,青田網(wǎng)站建設(shè)費(fèi)用合理。
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
For Each s In System.IO.Directory.GetDirectories("C:\Windows")
Console.WriteLine(System.IO.Path.GetFileName(s))
Next
End Sub
下面是部分輸出:
Application Data
AppPatch
assembly
BOCNET
Boot
Branding
ConfigSetRoot
Cursors
Debug
DigitalLocker
Downloaded Installations
Downloaded Program Files
ehome
en-US
Fonts
Globalization
Help
...
可能有更簡(jiǎn)潔的方法,你可以到MSDN看看
System.IO.Directory.GetDirectories:
System.IO.Path.GetFileName:
通用 I/O 任務(wù):
獲取方法,參考實(shí)例如下:
'獲取路徑名各部分: 如: 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(FilePathFileName)
J InStrRev(FilePathFileName, "\")
GetFileName Mid(FilePathFileName, J + 1, i)
End Function
''獲取路徑路徑 c:\dir1001\
Public Function GetFilePath(FilePathFileName As String) As String '獲取路徑路徑 c:\dir1001\
On Error Resume Next
Dim J As Integer
J InStrRev(FilePathFileName, "\")
GetFilePath Mid(FilePathFileName, 1, J)
End Function
'獲取文件名但不包括擴(kuò)展名 aaa
Public Function GetFileNameNoExt(FilePathFileName As String) As String '獲取文件名但不包括擴(kuò)展名 aaa
On Error Resume Next
Dim i As Integer, J As Integer, k As Integer
i Len(FilePathFileName)
J InStrRev(FilePathFileName, "\")
k InStrRev(FilePathFileName, ".")
If k 0 Then
GetFileNameNoExt Mid(FilePathFileName, J + 1, i - J)
Else
GetFileNameNoExt Mid(FilePathFileName, J + 1, k - J - 1)
End If
End Function
'===== '獲取擴(kuò)展名 .txt
Public Function GetFileExtName(FilePathFileName As String) As String '獲取擴(kuò)展名 .txt
On Error Resume Next
Dim i As Integer, J As Integer
i Len(FilePathFileName)
J InStrRev(FilePathFileName, ".")
If J 0 Then
GetFileExtName ".txt"
Else
GetFileExtName Mid(FilePathFileName, J, i)
End If
End Function
你把圖片要放在和程序一個(gè)文件夾下,然后就可以寫(xiě)成
PictureBox1.Image = System.Drawing.Image.FromFile("00.gif")
如果圖片在程序上層目錄下,就可以寫(xiě)成
PictureBox1.Image = System.Drawing.Image.FromFile("..\00.gif")
打開(kāi)Windows資源管理器,輸入路徑"C:\Users\Administrator\Desktop"即可進(jìn)入桌面。其中,Administrator為自定義管理員賬戶名稱。
你這個(gè)問(wèn)題分著問(wèn)興許能快點(diǎn)得到答案。
我只知道一點(diǎn),軟件已打開(kāi),可以根據(jù)進(jìn)程信息判斷
Private chm_process As Process
If IsNothing(chm_process) OrElse chm_process.HasExited Then
chm_process = New Process
chm_process.StartInfo.FileName = Application.StartupPath + "\軟件使用說(shuō)明書(shū).CHM"
chm_process.Start()
Else
WinAPI.ShowWindowEx(chm_process.MainWindowHandle, WinAPI.nCmdShow.SW_RESTORE)
End If
讓cad加載文件得找API,不知道有沒(méi)有