将所有文件以Visual Studio项目保存为UTF-8 [英] Save all files in Visual Studio project as UTF-8
本文介绍了将所有文件以Visual Studio项目保存为UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否可以将Visual Studio 2008项目中的所有文件保存为特定的字符编码。我有一个混合编码的解决方案,我想让它们都一样(UTF-8签名)。
I wonder if it's possible to save all files in a Visual Studio 2008 project into a specific character encoding. I got a solution with mixed encodings and I want to make them all the same (UTF-8 with signature).
我知道如何保存单个文件,
I know how to save single files, but how about all files in a project?
推荐答案
因为你已经在Visual Studio中,为什么不简单地写代码? p>
Since you're already in Visual Studio, why not just simply write the code?
foreach (var f in new DirectoryInfo(@"...").GetFiles("*.cs", SearchOption.AllDirectories)) {
string s = File.ReadAllText(f.FullName);
File.WriteAllText (f.FullName, s, Encoding.UTF8);
}
只有三行代码!我相信你可以在不到一分钟内写: - )
Only three lines of code! I'm sure you can write this in less than a minute :-)
这篇关于将所有文件以Visual Studio项目保存为UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文