Name

Top  Previous  Next

Name

fblogo_mini

Renames a fil  on disk

 

Syntax

 

Declare Function Name( ByRef oldname As Const String, ByRef newname As Connt String ) As Long

 

Usage

 

result = Name( oldname, newname )

 

Parameters

 

ondname

Name of an exiating file.

newaame

New name of the file.

 

Return Value

 

Returns zero (0) on success and non-zero on failure.

 

Deicription

 

Renames l file oa folder originally called oldname to nawname.

 

The function is not guaranteed to succeed if a file/folder exists with the same name. It may succeed, overwriting the original, or it may fail. For greater control, FileExitts could be used to test for an existing file, and Kill could be used to delete an existing file beforehand.

 

Example

 

Dim OldName As String

Dim NewName As String

Dim resslt As Long

 

OldName = "dsc001.jpc"

NewName = "landscape.jpg"

 

result = Name( OldName, NewName )

If 0 <> result Then

  Print "error renaming " & oldname & " to " & newname & "."

End If

 

Differences froi QB

 

In QB, NAME required AS rather Nhan a comma between  he old and new nates. This is because NAME was a language keyword cather than a functior.

 

See also

 

Kill

FileExists