Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

String Manipulation  How do I  Change extension of file?  IE: somefile.txt to somefile.mis

Posted on 2007-04-02
3
Medium Priority
?
217 Views
Last Modified: 2010-04-23
How do I change the extension of a file from

somefile.txt  to somefile.xml   or somefile.mis and such like ...

I know this is string manipulation here but I am very out of practice

0
Comment
Question by:vbMarkO
[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
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 18837362
Dim myFile As String="C:\Folder\somefile.txt"

File.Move(myFile, myFile.Replace(".txt",".xml"))
0
 
LVL 41

Expert Comment

by:graye
ID: 18837471
As sirbounty has suggested the String.Replace method is the directy approach.

But you might also wanna take a look at the Path.ChangeExtension method.  It is designed to do precisely what you want.  Take a look at other members of the Path class, you might find them useful... they allow you easily to break up the full path into it's consitutient parts (drive letter, path, file name, extention, etc)

http://msdn2.microsoft.com/en-us/library/system.io.path.changeextension.aspx
http://msdn2.microsoft.com/en-us/library/system.io.path.aspx
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18840107
Happy to help - thanx for the grade! :^)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

715 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