Solved

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

Posted on 2007-04-02
3
213 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

636 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