string resourceBackUpName = this.GetResourceBackUpName(resxFilePath);//back up the res file
            File.Copy(resxFilePath, resourceBackUpName);

 

            ResXResourceReader reader = new ResXResourceReader(resourceBackUpName);
            reader.UseResXDataNodes = true; // set it for get comments

            ResXResourceWriter writer = new ResXResourceWriter(resxFilePath);

            foreach (DictionaryEntry entry in reader)
            {
                ResXDataNode tmpNode = (ResXDataNode)entry.Value;

                AssemblyName[] assemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
                string theValue = tmpNode.GetValue(assemblies).ToString();

                ResXDataNode trimNode = new ResXDataNode(entry.Key.ToString(), theValue);
                trimNode.Comment =  tmpNode.Comment;

                writer.AddResource(trimNode);
            }
            reader.Close();
            writer.Close();

posted on 2011-03-17 20:14  Alan Yang  阅读(266)  评论(0编辑  收藏  举报