Solved

Changing File Names

Posted on 2004-10-18
4
294 Views
Last Modified: 2010-04-17
I'm a vb6 programmer.

I'm using FileListBox and the DirListBox.

I'm finding the files i want to find and in some cases would like to rename a file.
can this be done?  if so how do i do it?

b howard
0
Comment
Question by:BHoward
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
farsight earned 500 total points
ID: 12341758
To rename, use the FileSystemObject's MoveFile routine.

See: http://www.kcprogramming.com/vbfunctions.html
0
 
LVL 1

Expert Comment

by:liads
ID: 12342056
Visual Basic 6 has a statement that handles it. No need to create a special scripting object.

Simply use the Name statement:
Name <oldpath> As <newpath>

MSDN has all your VB needs: http://msdn.microsoft.com/library/en-us/vbenlr98/html/vastmname.asp
0
 
LVL 1

Expert Comment

by:liads
ID: 12342071
Ahhh... I'm too late... :-/
0
 
LVL 4

Expert Comment

by:Sicos
ID: 12342092
Just use the following code to rename a program

The code will return a false if it fails, otherwise it will return a true

Function RenameFile(lsSourceFile as string, lsDestinationFile as string) as boolean

      Dim oFSO

                on error goto ErrorHandler

      Set oFSO = CreateObject("Scripting.FileSystemObject")

      oFSO.MoveFile lsSourceFile, lsDestinationFile

      ' Clean Up
      Set oFSO = Nothing

      RenameFile = DTSTaskExecResult_Success

                exit function

ErrorHandler:
                RenameFile = false

End Function


Greetings,
Sicos
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
simplest php form 3 85
How to concatenate fields in zpl, and how to use conditional statement? 3 78
jboss 7.1 start up error 1 64
ejb entity bean example 2 39
A short article about a problem I had getting the GPS LocationListener working.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question