I try to replace the file name which contains “TEMPDOCUMENTLIBRARY” with “SHAREDDOCS” in the
docs (Typed Dataset). But somehow it does not replace it at all.
What’s wrong ?
for (int index = 0; index < docs.Document.Rows.Count; index++)
{
if (docs.Document[index].FileName.Contains("TEMPDOCUMENTLIBRARY"))
{
docs.Document[index].BeginEdit();
docs.Document[index].FileName.Replace("TEMPDOCUMENTLIBRARY", "SHAREDDOCS");
docs.Document[index].EndEdit();
}
}
Strings are immutable (meaning that the value of a given string never changes). Functions like
SubstringandReplacereturn new strings that represent the original string with the desired operations performed.In order to achieve what you want, you need this: