導航:首頁 > 文件教程 > vb文件的重命名

vb文件的重命名

發布時間:2023-05-06 23:43:32

㈠ VB中重命名文件

把D:\test\目錄下的所有抄jpg文件重命名為pic###.jpg的代碼襲:
Dim i As Integer
i = 1
Set fs = CreateObject("scripting.filesystemobject")
Set fd = fs.GetFolder("d:\test")
For Each f In fd.Files
If LCase(f.ShortName) Like "*.jpg" Then
f.Name = "pic" & Format(i, "000") & ".jpg"
i = i + 1
End If
Next

如果文件名已確定,可以用Set f=fs.GetFile("[完整路徑和文件名]"),然後用f.Name="[新文件名]"
另外提問的時候要注意把已知的條件和要達到的效果說清楚,「已知文件名的若干文件」到底是什麼樣的文件名,有沒有什麼規律?是否在同一文件夾下?或者是否已將文件名存放在一個字元串數組中?不說清楚別人怎麼能幫你,只能給你一個實現的思路了

㈡ VB中如何重命名文件夾

可以創建這個文件夾。
int i;
private void button1_Click(object sender, EventArgs e)
{
i++;

System.IO.DirectoryInfo FilePictures = new System.IO.DirectoryInfo(@"..\..\picture" + i);
if (!FilePictures.Exists)
{
FilePictures.Create();
}
}

㈢ VB怎麼重命名文件

Name"D:新建文件夾a.txt"As"d:新建文件夾.txt"

㈣ vb 文件改名

VB改名可以用name方法

Name oldpathname As newpathname

Name 語句的語法具有以下幾個部分:
oldpathname 必要參數。字元串表達式,指定已存在的文件名和位置,可以包含目錄或文件夾、以及驅動器。
newpathname 必要參數。字元串表達式,指定新的文件名和位置,可以包含目錄或文件夾、以及驅動器。而由 newpathname 所指定的文件名不能存在。

Name 語句重新命名文件並將其移動到一個不同的目錄或文件夾中。如有必要,Name 可跨驅動器移動文件。 但當 newpathname 和 oldpathname 都在相同的驅動器中時,只能重新命名已經存在的目錄或文件夾。 Name 不能創建新文件、目錄或文件夾。

在一個已打開的文件上使用 Name,將會產生錯誤。必須在改變名稱之前,先關閉打開的文件。Name 參數不能包括多字元 (*) 和單字元 (?) 的統配符。

經查閱MSDN里,VB里沒有moveto方法改名,其他語言有~~下面是MoveTo 方法
MoveTo Method (Folder Object)
The MoveTo method relocates the Folder object to another folder hierarchy location.

Syntax
Set objMovedFolder = objFolder.MoveTo(folderID [, storeID ] )

objMovedFolder
On successful return, contains the moved Folder object.
objFolder
Required. This Folder object.
folderID
Required. String. The unique identifier of the new parent Folder object, that is, the Folder object under which this folder is to appear as a subfolder.
storeID
Optional. String. The unique identifier of the InfoStore object in which this folder is to appear, if different from its current InfoStore.
Remarks
All subfolders of this folder, together with all Message objects contained within this folder and its subfolders, are moved along with the folder itself.

The move operation takes effect immediately. This Folder object is no longer accessible at its former location after the MoveTo method returns.

㈤ 如何用vb修改文件名

二次補充:肯定沒問題了,把其他功能都去掉了,只剩下改名和刪除,如果想吧刪除去掉,就去注釋的那一句。
============
建一個Command1,如果需要,建立Command2。
代碼如下。
============
Dim t As Integer, s As String
Private Sub Command1_Click()
Name "c:\abc\temp_" & t & ".txt" As "c:\abc\temp.txt"
Kill "c:\abc\temp.txt" '不刪除的話去掉這一句
t = t + 1
If t = 151 Then End '比方說你想進行到文件150,就要寫上151
End Sub

Private Sub Form_Load()
t = 121
End Sub

㈥ 在VB中如何重命名一個文件

用重命名語句,例如把C盤的格式為mp3,文件名為A的改為B:Name C:\A.mp3 As C:\B.mp3

㈦ vb窗體文件怎麼重命名

VB6中執行「文件」菜單中的「Form1另存為」(Form1代表你當前窗體名稱),或者在工程資源管理器窗口,右擊要重命名的窗體,在彈出的快捷菜單中執行「Form1另存為」(Form1代表你當前窗體名稱)。
窗體文件重命名後,一定要保存工程文件

㈧ 用VB批量重命名文件,如何實現

方法一:Dim fpPrivate Sub refilename(folderspec)Dim fs, f, f1, fc, sm, hzSet fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)Set fc = f.FilesFor Each f1 In fc
hz = Mid(f1.Name, InStrRev(f1.Name, "."))
Name f1 As fp & "20101007-" & hz
NextMsgBox "修改完成"End SubPrivate Sub Command1_Click()fp = "E:\emot\xhh\"'這里設置文件夾路徑,根的需要來修改
If Right(fp, 1) <> "\" And Right(fp, 1) <> "/"
Then fp = fp & "\"Call refilename(fp)
』調用上面的自定義函數,改名End Sub........

方法二: '將f:\123\文件下的txt文件改名
Dim files() As String '用於貯存文件名
Dim length As Integer = 0 'files數組長度
Dim fileName As String = Dir$("f:\123\*.txt") '得到第一個.txt文件的文件名
'Dim g As Graphics = Me.CreateGraphics
Do While fileName <> ""
'g.DrawString(length, Font, Brushes.Red, length * 10, length * 10)
ReDim Preserve files(length)
files(length) = fileName
length = files.Length
fileName = Dir$() '得到下一個.txt文件的文件名
Loop
For i = 0 To length - 1
Dim oldfileName As String = "f:\123\" + files(i)
Dim newfileName As String = "f:\123\" + "20101007_"+ files(i)
Rename(oldfileName, newfileName) '修改文件名
Next

閱讀全文

與vb文件的重命名相關的資料

熱點內容
win10刪除c盤文件會刪掉系統嗎 瀏覽:785
qq的獨立密碼怎麼取消 瀏覽:289
後台的商品數據在哪裡看 瀏覽:795
不用網路載入的單機游戲有哪些 瀏覽:608
數據線插頭怎麼接頭 瀏覽:577
網路載入視頻失敗是怎麼回事 瀏覽:805
傳奇賬號在哪個文件夾里 瀏覽:346
百度app在哪裡安裝 瀏覽:587
如何設置路由器網路不斷網 瀏覽:471
傳到qq群里的文件怎麼刪除 瀏覽:861
索尼安卓71更新日誌 瀏覽:234
怎麼找手機里的垃圾app 瀏覽:540
2015藍橋杯代碼填空 瀏覽:698
安卓資料庫dbexecSQL 瀏覽:227
doc重命名文件格式 瀏覽:728
getscreen截圖工具下載 瀏覽:719
共識數據是什麼時候開始的 瀏覽:96
數碼管顯示電壓程序 瀏覽:479
資料庫文件有哪個 瀏覽:543
途強儲存在哪個文件夾 瀏覽:172

友情鏈接