A few things:
IGet3rdPartyStorage: This works only when a particular notification fires "SaveToStorageNotify"
True. But you can also use the SWDocumentMgr API, and in particular ISwDMDocument19.Get3rdPartyStorage.
Since the PersistentID is essentially a list of bytes, you can just store those bytes directly into the Stream. The example given in the API help for the ISwDMDocument19.Get3rdPartyStorage method is very close to what you want:
Public Sub Write3rdPartyStorageData()
Dim pIStream As IStream = Nothing
pIStream = swDoc19.Get3rdPartyStorage(txtStorageName.Text, True)
If pIStream Is Nothing Then
rtbStorage.Text = "Error: " + "Storage " + txtStorageName.Text + " not found"
Dim strStream As Byte() = Nothing
strStream = Encoding.UTF8.GetBytes(rtbStorage.Text)
Dim outlength As UInteger = 0
pIStream.Write(strStream, CUInt(strStream.Length), outlength)
Catch ex As Exception
rtbStorage.Text = "Error: " + ex.Message
Finally, for the .Net 4 bit, it looks like you are trying to register the dll with the .Net 2 regasm tool.
Try using the one in the C:\Windows\Microsoft.NET\Framework64\v4.0.30319 folder
Thanks for the tips.
A few questions remain.
1. Is it possible to programmatically fire the FiletoStorageNotify . ?
2. Can the DocumentManagerApi be used in and active session to write to the 3rd party storage of an open
3.Does the FileStream object write directly to the third party storage without the need for the streamwriter or streamreader.
I presume if either is used then a string conversion becomes necessary.
I was able to resolve most of the other issues of saving and retrieving using the streamreader and streamwriter.
The only issue remaining is to write to the storage without having to wait for the user to save the file.
Thanks for the reply. Appreciate the help and insights.
1. Looking at the documentation for IGet3rdPartyStorage: "When a file is fully loaded, you can call this method for reading your data at any time"
So you don't need to wait for LoadFromStorageNotify. Just don't use it during FileSaveNotify or FileOpenNotify2.
2. If the file is open, use IGet3rdPartyStorage as above.
3. Anything that inherits from Stream can be used. However, I would personally convert the persistent ID to a string and use StreamWriter.
Hope that helps.