vb.net文件改别名 vb文件名称

用vb怎样这样修改文件名?Private Sub command1_click()
Dim d As String
d = Dir("c:\abc\*.txt")
Do Until d = ""
Name "c:\abc\"d As "c:\abc\"Text1.Textd
d = Dir
Loop
End Sub
以上代码是把"c:\abc"目录的所有txt的文件名前面插入text1的内容 。如果只想给最新创建的文件添加,那么可以在循环中用FileDateTime("c:\abc\"d)检测文件的时间,找出最新的那个即可 。
怎么用VB.NET更改文件扩展名以修改“C:\abc.txt"为bat为例 。
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Myfile As String
【vb.net文件改别名 vb文件名称】Myfile = IO.Path.ChangeExtension("C:\abc.txt", ".bat")
Microsoft.VisualBasic.FileSystem.Rename("C:\abc.txt", Myfile)
End Sub
End Class
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.net文件改别名和vb文件名称的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读