Solved

Renaming File Types

Posted on 2006-06-27
4
174 Views
Last Modified: 2011-09-20
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 :)
0
Comment
Question by:NAORC
[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
4 Comments
 
LVL 15

Expert Comment

by:cquinn
ID: 16993744
Why not create the file as C:\update.bat in the first place?

0
 
LVL 5

Author Comment

by:NAORC
ID: 16993763
Set m_destTS = m_fso.CreateTextFile("C:\ORCGravity\update.txt", True)

^^throws up errors if i do^^
0
 
LVL 13

Accepted Solution

by:
Mark_FreeSoftware earned 125 total points
ID: 16993827
try this:

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

now you have "c:\update.bat" in tmp!
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16993882
"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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

739 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