|
-
Jan 19th, 2000, 07:12 AM
#1
Thread Starter
New Member
Hello!
I'm making a demo save utility
for Action Quake 2 and I would
like to know how to rename files
with VB. Like this:
Original name: demo1.dm2
The new name : cooldemo1.dm2
hope you can help / [email protected]
-
Jan 19th, 2000, 07:23 AM
#2
From MSDN Help
=================================
Name Statement Example
This example uses the Name statement to rename a file. For purposes of this example, assume that the directories or folders that are specified already exist.
Dim OldName, NewName
OldName = "OLDFILE": NewName = "NEWFILE" ' Define file names.
Name OldName As NewName ' Rename file.
OldName = "C:\MYDIR\OLDFILE": NewName = "C:\YOURDIR\NEWFILE"
Name OldName As NewName ' Move and rename file.
=====================================
I would change
Dim OldName, NewName
to
Dim OldName as String
Dim NewName as String
Better yet would be to also change the names to strOldName and strNewName or sOldName and sNewName.
------------------
Marty
-
Jan 19th, 2000, 07:35 AM
#3
New Member
-
Jan 19th, 2000, 09:18 PM
#4
Junior Member
One way to do this is to use the API call:
Declare Function MoveFile Lib "kernel32.dll" Alias "MoveFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long
And then use this code (remember to change the directory from C:\ to whatever dir the files are in):
Dim ret As Long
ret = MoveFile("c:\demo1.dm2", "c:\cooldemo1.dm2")
-
Jan 19th, 2000, 09:19 PM
#5
Junior Member
One way to do this is to use the API call:
Declare Function MoveFile Lib "kernel32.dll" Alias "MoveFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long
And then use this code (remember to change the directory from C:\ to whatever dir the files are in):
Dim ret As Long
ret = MoveFile("c:\demo1.dm2", "c:\cooldemo1.dm2")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|