Siebel VB Language Reference > Methods Reference for Siebel VB > File Control Methods >

Rename File Method


The Rename File method renames a file or copies a file from one directory to another directory. It does not return a value. The file that this method renames must be closed. Siebel VB creates an error message in the following situations:

  • The file that the oldfilename argument identifies is open.
  • The file that the newfilename argument identifies already exists.

If you use the Rename File method with a Siebel application, and if you do not include the path2 argument, then it places a copy of the original file in the following directory under the new name:

c:\siebel\bin

Format

Name [path1\]oldfilename As [path2\]newfilename

The following table describes the arguments that you can use with this method.

Argument
Description

path1

A string expression that contains the path to the current file location. If the file is not in the current directory of the current drive, then you must include this argument.

oldfilename

A string expression that contains the name of the file that this method renames.

path2

A string expression that contains the path to the location where the renamed file must reside. If you do not include this argument, then this method saves the file in the current directory of the current drive.

newfilename

A string expression that contains the new name for the file.

Example

The following example creates the c:\temp001 file, renames this file to c:\temp002, and then deletes these files. It calls the CreateFile subroutine 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

Siebel VB Language Reference Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Legal Notices.