更改文件的扩展名 [英] change the extension of a file

查看:95
本文介绍了更改文件的扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hiee guys

我有一个阙。请给我回复

如何使用C#

更改文件的扩展名,例如: - .dat文件到.xls





提前使用Thanxx

解决方案

http://heathesh.com/post/2009/10/01/Change-a-file-extension -using-C-(rename-a-file).aspx [ ^ ]

http://stackoverflow.com/questions/5259961/change-file-extension-c-sharp [ ^ ]



或者 Goooooooogle [ ^ ]


请参阅下面的链接

希望它对您有所帮助。

链接1 [ ^ ]



>链接2

[ ^ ]

一切顺利


< b lockquote>嗯..让我解释一下。



用.NET改变文件的文件名(也不是扩展名)是不可能的。这只是没有实现。



但你可以这样做:将现有文件的内容复制到一个新文件中(根据需要命名),然后删除源文件。



  private   void  RenameFile( string  filename, string  newFileName)
{
File.WriteAllText(newFileName,File.ReadAllText(filename,Encoding.Default));
File.Delete(filename);
}





问帕特里克


hiee guys
I have a que. plz give me reply
how to change the extension of a file using C#
eg:- .dat file to .xls


Thanxx in advance

解决方案

http://heathesh.com/post/2009/10/01/Change-a-file-extension-using-C-(rename-a-file).aspx[^]
http://stackoverflow.com/questions/5259961/change-file-extension-c-sharp[^]

or else Goooooooogle[^]


Refer Below Link
Hope it will help full for you.
Link 1[^]

Link 2
[^]
all the best


hmm.. let me explain.

It is not possible to change a filename (nor the extension) of a file with .NET. This just is not implemented.

BUT you can do as follows: Copy the content of the existing file into a new file (name it as you want), afterwards delete the source file.

private void RenameFile(string filename, string newFileName)
{
    File.WriteAllText(newFileName, File.ReadAllText(filename, Encoding.Default));
    File.Delete(filename);
}



regards Patrick


这篇关于更改文件的扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆