I got this working. And I am posting the code here for anyone having the same requirement.
var buffer = IsolatedStorageHelper.ReadFileFromIsolatedStorage
(filename);
WordDocument document;
using (Stream stream = new MemoryStream(buffer))
{
document = new WordDocument(stream,
FormatType.Doc);
}
var bn = new BookmarksNavigator(document);
bn.MoveToBookmark("Bookmark1");
//Getting first book mark content
var bookmarkContent1 = bn.GetBookmarkContent();
bn.MoveToBookmark("Bookmark2");
//Replacing the second bookmark content with first
//bookmark content
bn.ReplaceBookmarkContent(bookmarkContent1);
using (var writer = new MemoryStream())
{
document.Save(writer, FormatType.Doc);
IsolatedStorageHelper.StoreFileToIsolated
(filename, writer.GetBuffer());
}
And my isolated storage helper class looks as follows
public static byte[] ReadFileFromIsolatedStorage(string
fileName)
{
byte[] retVal;
using (IsolatedStorageFile iso =
IsolatedStorageFile.GetUserStoreForApplication())
{
if (iso.FileExists(fileName))
{
using (IsolatedStorageFileStream stream =
iso.OpenFile(fileName, FileMode.Open))
{
retVal = new byte[stream.Length];
stream.Read(retVal, 0, retVal.Length);
}
}
else
{
retVal = new byte[0];
}
}
return retVal;
}
public static void StoreFileToIsolated(string path, byte
[] data)
{
var iso =
IsolatedStorageFile.GetUserStoreForApplication();
using (var isoStream = new IsolatedStorageFileStream
(path, FileMode.Create, iso))
{
isoStream.Write(data,0,data.Length);
}
}