Renaming File Types

Hi Guys.. easy one for y'all..

I have a program that feeds lines of text into a .txt file (C:\update.txt)

the way i have designed it to output the results means if i change the file extension to .bat, it will become a working batch file.  how do i change the extension in vb6?

I do have filesystemobject setup and running :)
LVL 5
NAORCAsked:
Who is Participating?
 
Mark_FreeSoftwareConnect With a Mentor Commented:
try this:

dim tmp as string
tmp = "c:\update.txt"
tmp = replace(tmp,".txt",".bat")

now you have "c:\update.bat" in tmp!
0
 
cquinnCommented:
Why not create the file as C:\update.bat in the first place?

0
 
NAORCAuthor Commented:
Set m_destTS = m_fso.CreateTextFile("C:\ORCGravity\update.txt", True)

^^throws up errors if i do^^
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
"how do i change the extension in vb6?"

In VB6, you can use the Name function to rename a file:

    Dim oldFileName As String
    Dim newFileName As String
   
    oldFileName = "c:\someFile.txt"
    newFileName = "c:\someFile.bat"
   
    Name oldFileName As newFileName
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.