Unable to update MS tag using Microsoft.WindowsAPICodePack.Shell.PropertySystem .tmp files are getting created

Hiras, Amit 1 Reputation point
2023-01-06T10:01:47.517+00:00

I am using .net core 6 console app to write tags to Microsoft Files like Word/Excel, in some cases, the code is creating .tmp files and not updating the tag of the file, the code does not throw any exceptions as well.
Kindly suggest a way to write file tag programmatically or let me know what I need to correct in the below code.

using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;

                var shellFile = ShellFile.FromFilePath(filePath);  
                ShellPropertyWriter propertyWriter = shellFile.Properties.GetPropertyWriter();  
                propertyWriter.WriteProperty(SystemProperties.System.Keywords, tag);                      
                propertyWriter.Close();  
                propertyWriter.Dispose();
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,574 questions
Word Management
Word Management
Word: A family of Microsoft word processing software products for creating web, email, and print documents.Management: The act or process of organizing, handling, directing or controlling something.
900 questions
PowerPoint Management
PowerPoint Management
PowerPoint: A family of Microsoft presentation graphics products that offer tools for creating presentations and adding graphic effects like multimedia objects and special effects with text.Management: The act or process of organizing, handling, directing or controlling something.
222 questions
Excel Management
Excel Management
Excel: A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.Management: The act or process of organizing, handling, directing or controlling something.
1,657 questions
{count} votes