Siebel VB Language Reference > VB Language Reference >
Name Statement
This standard VB statement renames a file or copies a file from one folder to another. Syntax
Name [path1\]oldfilename As [path2\]newfilename
|
|
path1\ |
A string expression containing the path to the current location of the file (must be entered if the file is not in the current folder of the current drive) |
oldfilename |
A string expression containing the name of the file to be renamed |
path2\ |
A string expression containing the path to the location where the renamed file should appear; if a path is not given, the file goes in the current folder of the current drive |
newfilename |
A string expression containing the new name for the file |
Returns
Not applicable Usage
To be renamed, the file must be closed. If the file oldfilename is open or if the file newfilename already exists, Siebel VB generates an error message. If this statement is used within the Siebel application, and no path2\ is specified, a copy of the original file goes in the c:\siebel\bin folder under the new name. Example
This example creates a temporary file, c:\temp001 , renames the file to c:\temp002 , then deletes them both. It calls the subprogram CreateFile to create the c:\temp001 file. (general) (declarations) Option Explicit Declare Sub CreateFile
Sub CreateFile Rem Put the numbers 1-10 into a file Dim x as Integer Dim y() Dim startletter Open "C:\TEMP001" for Output as #1 For x = 1 to 10 Write #1, x Next x Close #1 End Sub
Sub Button_Click Call CreateFile On Error Resume Next Name "C:\TEMP001" As "C:\TEMP002" Kill "TEMP001" Kill "TEMP002" End Sub
See Also
FileAttr Function FileCopy Statement GetAttr Function Kill Statement
|