Solved

Changing File Names

Posted on 2004-10-18
4
280 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
Comment Utility
To rename, use the FileSystemObject's MoveFile routine.

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

Expert Comment

by:liads
Comment Utility
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
Comment Utility
Ahhh... I'm too late... :-/
0
 
LVL 4

Expert Comment

by:Sicos
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now