Esempio n. 1
0
        public void SetPropsTest2()
        {
            const string fn      = "test.docx";
            var          fp      = Path.Combine(ShellFolder.Desktop.FileSystemPath, fn);
            var          authors = new[] { "David" };

            using (var p = new ShellItemPropertyUpdates {
                { PROPERTYKEY.System.Author, authors }
            })
                using (var op = new ShellFileOperations())
                {
                    op.PostNewItem += HandleEvent;
                    op.QueueNewItemOperation(ShellFolder.Desktop, fn, template: @"C:\Users\dahall\Documents\Custom Office Templates\blank.dotx");
                    op.QueueApplyPropertiesOperation(new ShellItem(fp), p);
                    op.PerformOperations();
                }
            Assert.That(new ShellItem(fp).Properties[PROPERTYKEY.System.Author], Is.EquivalentTo(authors));
            File.Delete(fp);

            void HandleEvent(object sender, ShellFileOperations.ShellFileOpEventArgs args)
            {
                Debug.WriteLine(args);
                Assert.That(args.Result.Succeeded, Is.True);
            }
        }