Solved

Renaming File Types

Posted on 2006-06-27
4
170 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
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 85

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

929 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

10 Experts available now in Live!

Get 1:1 Help Now