Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Changing File Names

Posted on 2004-10-18
4
Medium Priority
?
299 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 2000 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Simple Linear Regression
Progress

604 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