Error while settings Custom DSOFile Properties

-1

I'm working on a C# app that will add some custom fileproperties to some word files... If I only set the SummaryProperties the app works fine but when I try to set CustomProperties I got the following Error when I save the changes:

{"Invalid parameter error (exception from HRESULT: 0x80030057 (STG_E_INVALIDPARAMETER))"}

Does someone else got this error and know how to solve it?

Here is my code:

try
{
    var doc = new OleDocumentPropertiesClass();
    doc.Open(document.Path, false, dsoFileOpenOptions.dsoOptionDefault);

    var fileProperties = _library.GetProfile(document.DocNumber);

    if (_settings.ExportSettings.Metadata.Y)
    {
        object value = !string.IsNullOrEmpty(fileProperties.Property("Y"))
                       ? fileProperties.Property("Y")
                       : "UNKNOWN";
        doc.CustomProperties.Add("Y", value);
    }

    if (_settings.ExportSettings.Metadata.x)
    {
        string value = !string.IsNullOrEmpty(fileProperties.Property("x"))
                       ? fileProperties.Property("x")
                       : "UNKNOWN";
        doc.CustomProperties.Add("X", value);
    }

    doc.Save();
    doc.Close();
}
catch (Exception exception)
{
    _logger.Error($"Failed to set property for document #{document.DocNumber}: {exception.Message}", exception);
}
c#
.net
dsofile
asked on Stack Overflow May 20, 2020 by Blanko • edited May 20, 2020 by Blanko

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0