将 Visual Studio 项目中的所有文件另存为 UTF-8 [英] Save all files in Visual Studio project as UTF-8

查看:193
本文介绍了将 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 中,为什么不直接编写代码?

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屋!

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