Solved

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

Posted on 2007-04-02
3
163 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
  • 2
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

21 Experts available now in Live!

Get 1:1 Help Now