Solved

Changing File Names

Posted on 2004-10-18
4
292 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
  • 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

803 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