Use ASP to modify the file name
For example, if a file already exists and the path is 'd: \ files \ test. asp, I want to change it to new. asp and the path remains unchanged. How should I write it?
As follows:
Set fso = Server. CreateObject ("Scripting. FileSystemObject ")
Set f = fso. GetFile ("d: \ files \ test. asp ")
F. name = "new. asp"
Newname = f. name
Response. write newname is displayed as: new. asp
Another method is as follows:
Set fso = Server. CreateObject ("Scripting. FileSystemObject ")
Fso. movefile "d: \ files \ test. asp", "d: \ files \ new. asp"
========================================================== ==========================================================
Name attribute
Description
Sets or returns the name of the specified file or folder. Read/write attributes.
Syntax
Object. Name [= newname]
The Name attribute has the following parts:
Partial description
Required. It is always the name of a File or Folder object.
Newname is optional. If yes, newname is the new name of the specified object.
Description
The following code illustrates the usage of the Name attribute:
Sub ShowFileaccessInfo (filespec)
Dim fs, f, s
Set fs = CreateObject ("Scripting. FileSystemObject ")
Set f = fs. GetFile (filespec)
S = f. Name & "on Drive" & UCase (f. Drive) & vbCrLf
S = s & "Created:" & f. DateCreated & vbCrLf
S = s & "Last accessed:" & f. DateLastaccessed & vbCrLf
S = s & "Last Modified:" & f. DateLastModified
MsgBox s, 0, "File access Info"
End Sub