?
Solved

Changing File Names

Posted on 2004-10-18
4
Medium Priority
?
298 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
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 …
Progress
Suggested Courses

752 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