how to change filetype?

  • Thread starter Thread starter lizhx
  • Start date Start date
L

lizhx

i have a file "a.mp3"
but i want wo change it to "a.asf"(not in convert,only to change the file
header and extent)

how to?

thanks
 
I believe you are looking for the Path.ChangeExtension (System.IO
namespace).

ShaneB
 
i have a file "a.mp3"
but i want wo change it to "a.asf"(not in convert,only to change the file
header and extent)

how to?

thanks

To change file extensions this works well

string newFilename = openFileDialog1.FileName;
newFilename = newFilename.Substring(0, filename.LastIndexOf(@".")) +
".asf";
File.Move(openFileDialog1.FileName, newFilename);
 
For some reason I thought he was just trying to change the filename as a
string...it's early here :) Combining with Arne's code, we get:

string newFilename = openFileDialog1.FileName;
File.Move( openFileDialog1.FileName,
Path.ChangeExtension(openFileDialog1.FileName, ".asf") );

ShaneB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top