Example #1
0
        public void MoveItemTest()
        {
            // Delete item to Recycle Bin
            using var tmp = new TempFile();
            Assert.That(() => ShellFileOperations.Delete(tmp.FullName), Throws.Nothing);

            // Find deleted item
            using var bin = new ShellFolder(KNOWNFOLDERID.FOLDERID_RecycleBinFolder);
            var item = bin.FirstOrDefault(si => si.Name == tmp.FullName);

            Assert.NotNull(item);

            // Restore item
            using var dest = new ShellFolder(Path.GetDirectoryName(tmp.FullName));
            Assert.That(() => ShellFileOperations.Move(item, dest, null, ShellFileOperations.OperationFlags.NoConfirmation), Throws.Nothing);
            Assert.IsTrue(File.Exists(tmp.FullName));
        }