Connecting Tech Pros Worldwide Forums | Help | Site Map

how to change filetype?

lizhx@0536.net
Guest
 
Posts: n/a
#1: Nov 16 '05
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


ShaneB
Guest
 
Posts: n/a
#2: Nov 16 '05

re: how to change filetype?


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

ShaneB

"lizhx@0536.net" <lixi0179@sina.com.cn> wrote in message
news:OtkLP8IyEHA.2776@TK2MSFTNGP10.phx.gbl...[color=blue]
>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
>
>[/color]


Arne Schittenhelm
Guest
 
Posts: n/a
#3: Nov 16 '05

re: how to change filetype?


On Fri, 12 Nov 2004 16:10:15 +0800, "lizhx@0536.net"
<lixi0179@sina.com.cn> wrote:
[color=blue]
>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
>[/color]

To change file extensions this works well

string newFilename = openFileDialog1.FileName;
newFilename = newFilename.Substring(0, filename.LastIndexOf(@".")) +
".asf";
File.Move(openFileDialog1.FileName, newFilename);
ShaneB
Guest
 
Posts: n/a
#4: Nov 16 '05

re: how to change filetype?


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

<Arne Schittenhelm> wrote in message
news:jo19p0h491te931bsqtelau19plf7f67k5@4ax.com...[color=blue]
> On Fri, 12 Nov 2004 16:10:15 +0800, "lizhx@0536.net"
> <lixi0179@sina.com.cn> wrote:
>[color=green]
>>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
>>[/color]
>
> To change file extensions this works well
>
> string newFilename = openFileDialog1.FileName;
> newFilename = newFilename.Substring(0, filename.LastIndexOf(@".")) +
> ".asf";
> File.Move(openFileDialog1.FileName, newFilename);[/color]


Closed Thread