在sharepoint中为了翻译字段,我必须修改一个名为schemaxml的属性。
当我用c#读取它时,我得到的代码是这样的:
string schemaXmlWithResourceTokens = recurrentField.SchemaXmlWithResourceTokens;
int startIndex = schemaXmlWithResourceTokens.IndexOf("\"", schemaXmlWithResourceTokens.IndexOf("DisplayName=\"")) + 1;
int endIndex = schemaXmlWithResourceTokens.IndexOf("\"", startIndex);
int substringLength = endIndex - startIndex;
string value = @"DisplayName=\" + schemaXmlWithResourceTokens.Substring(startIndex, substringLength);
schemaXmlWithResourceTokens = schemaXmlWithResourceTokens.Replace(value, @"DisplayName=\$Resources:SPNLMeetings,Field_Recurrent_Name");
recurrentField.SchemaXml = schemaXmlWithResourceTokens;
recurrentField.Update();
值未被更改。
答案 0 :(得分:1)
试试这个:
string value = "DisplayName=\"" + schemaXmlWithResourceTokens.Substring(startIndex, substringLength);
差异为"DisplayName=\""
而非@"DisplayName=\"