Пример #1
0
        public static void MoveToTrash(ICollection <FileSystemInfo> collection)
        {
            try
            {
                if (collection.Count == 0 && collection == null)
                {
                    throw new Exception("Attempted to delete the same file  twice");
                }

                foreach (var fi in collection)
                {
                    if (collection.Count(e => e == fi) != 1)
                    {
                        throw new Exception("Attempted to delete the same file  twice");
                    }
                }

                foreach (var fi in collection)
                {
                    if (ShellUtilities.SendToRecycle(fi.FullName, ShellUtilities.FileOperationFlags.FOF_WANTNUKEWARNING) == false)
                    {
                        throw new Exception("Unhandled error");
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.Message == "Unhandled error")
                {
                    RecycleBin.Restore(collection);
                }
            }
        }
Пример #2
0
 public void InvokeEvent()
 {
     RecycleBin.MoveToTrash(RestoreCollection);
 }
Пример #3
0
 public void GetBack()
 {
     RecycleBin.Restore(RestoreCollection);
 }