以修改“C:\abc.txt"為bat為例。
創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括通榆網(wǎng)站建設(shè)、通榆網(wǎng)站制作、通榆網(wǎng)頁(yè)制作以及通榆網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,通榆網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到通榆省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Myfile As String
Myfile = IO.Path.ChangeExtension("C:\abc.txt", ".bat")
Microsoft.VisualBasic.FileSystem.Rename("C:\abc.txt", Myfile)
End Sub
End Class
一般放在你的可執(zhí)行文件的目錄下,也有放在系統(tǒng)的路徑下,
還可放在任意目錄下,不過(guò)要在path中設(shè)置路徑。
獲取方法,參考實(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