Problem with editing a translation unit programmatically

Anonymous
Offline Anonymous

Hallo,

I am trying to use the code I found in one of  the API documentation examples (Updating a Translation Memory), but it doesn't work.I receive no exception, but the code does nothing to the translation memory.The translation memory is not protected with password or something like that..I can write new entries to the translation memory file, I can delete entries but it seems that I cannot perform an edit.

Here is the code:

FileBasedTranslationMemory tm=new FileBasedTranslationMemory();           

SearchSettings settings = new SearchSettings();
 settings.MinScore = 100;
 settings.MaxResults = 1;
  SearchResults results = tm.LanguageDirection.SearchText(settings, oldTargetSegment);
            foreach (SearchResult item in results)
            {
                if (item.ScoringResult.Match == 100)
                {
                    item.MemoryTranslationUnit.TargetSegment.Clear();
                    item.MemoryTranslationUnit.TargetSegment.Add(newTargetSegment);
                    item.MemoryTranslationUnit.SystemFields.UseCount++;
                    break;
                }
            }

  tm.Save();

Did anyone encounter the same porblem?

Thanks in advance!