My software exports pdf files and put them in a vault. These file can be created in a single or multi file document (and this works fine).
If a file is exported more times, I should replace the file and put the new file.
Now, I tried to do this:
- destroy the document and re-create it (but I don't know why this doesn't work - see this post http://community.m-files.com/index.php?topic=1147.0)
- check-out the document, remove the file and put the new file in this way
Set oResults = oVault.ObjectSearchOperations.SearchForObjectsByConditions(arrCondizioni, MFilesAPI.MFSearchFlags.MFSearchFlagNone, False)
If oResults.Count > 0 Then
oVault.ObjectOperations.CheckOut oResults(1).ObjVer.ObjID
Dim objVersion As MFilesAPI.ObjVer
Set objVersion = New ObjVer
objVersion.SetObjIDAndVersion oResults(1).ObjVer.ObjID, CLng(oResults(1).ObjVer.Version) + 1
oVault.ObjectFileOperations.RemoveFile objVersion, oResults(1).Files(1).FileVer
oVault.ObjectFileOperations.AddFile objVersion, GetFileName(pathFile), "pdf", pathFile
[...]
When I call the ".RemoveFile" method, it throws an error saying "Not found."... I think that the way I set FileVer parameter is not correct... I didn't found informations about using FileVer...
Also, if the document is a "Single file document". the ".RemoveFile" throws an error saying that I can't remove a file from a single-file document... so, how can I replace this file?
If somebody can help me, I will be very grateful!!!
Thank you very much.
davides