static void Main(string[] args)
        {
            
string pResources = @"D:\Resource\";
            DirectoryInfo diResources 
= new DirectoryInfo(pResources);
            var queryList 
= diResources.GetFiles();
            
foreach (var ary in queryList)
            {
                TestToResources(pResources 
+ ary.Name, @"D:\ResX\" + ary.Name.Replace("resources.""").Replace(".resources"".resx"));
            }
        }

        
static void TestToResources(string strResource, string strResx)
        {
            ResourceReader reader 
= new ResourceReader(strResource);
            ResXResourceWriter writer 
= new ResXResourceWriter(strResx);

            
foreach (DictionaryEntry en in reader)
            {
                writer.AddResource(en.Key.ToString(), en.Value);
            }
            reader.Close();
            writer.Close();
        }

这里可以使用Artech的扩展方法

namespace System
 2: {
class StringExtensions
 4: {
false)
 6: {
string.Empty;
if(!sourceString.StartsWith(prefix,ignoreCase, CultureInfo.CurrentCulture))
 9: {
return sourceString;
 11: }
 12:  
return sourceString.Remove(0, prefix.Length);
 14: }
 15:  
false)
 17: {
string.Empty;
if (!sourceString.EndsWith(suffix, ignoreCase, CultureInfo.CurrentCulture))
 20: {
return sourceString;
 22: }
return sourceString.Substring(0, sourceString.Length - suffix.Length);
 24: }
 25: }
 26: }

程序调用:

string[] args)
 2: {
;
));
));
 6: }

输出结果:

 1: 123
 2: ABC

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2021-11-17
  • 2021-08-03
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-06
  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2021-08-27
  • 2022-01-24
相关资源
相似解决方案