Solved

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

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

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

Title # Comments Views Activity
DataGridview Currency Formating? 22 53
Form design in vb.net 7 34
Definitions and default visual studio colors 5 58
Get Client IP on RDS - VB.NET 15 25
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 …
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 …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

19 Experts available now in Live!

Get 1:1 Help Now