private void EmptyRecycleBin()
        {
            ProgressManager progress = new ProgressManager();

            Progress.Steps.Add(new SteppedProgressManagerStep(progress,
                                                              0.0f, S._("Emptying recycle bin...")));

            RecycleBin.Empty(EmptyRecycleBinOptions.NoConfirmation |
                             EmptyRecycleBinOptions.NoProgressUI | EmptyRecycleBinOptions.NoSound);
        }
 public static bool EmptyRecycleBin()
 {
     try
     {
         RecycleBin.Empty();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #3
0
 public static bool EmptyRecycleBin()
 {
     try
     {
         RecycleBin.Empty(false);
         return(true);
     }
     catch (Exception ex)
     {
         LogTracer.Log(ex, $"An exception was threw in {nameof(EmptyRecycleBin)}");
         return(false);
     }
 }
Beispiel #4
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            var options = RecycleBin.EmptyOptions.Default;

            if (ShowConfirmation)
            {
                options ^= RecycleBin.EmptyOptions.NoConfirmation;
            }
            if (ShowProgressUI)
            {
                options ^= RecycleBin.EmptyOptions.NoProgressUI;
            }
            if (PlaySound)
            {
                options ^= RecycleBin.EmptyOptions.NoSound;
            }

            if (PathRoot == null)
            {
                try
                {
                    RecycleBin.Empty(Container, options: options);
                }
                catch (Exception e)
                {
                    WriteError(e.ToErrorRecord());
                }

                return;
            }

            foreach (var path in PathRoot)
            {
                try
                {
                    RecycleBin.Empty(Container, path, options);
                }
                catch (Exception e)
                {
                    WriteError(e.ToErrorRecord());
                }
            }
        }
Beispiel #5
0
        public void EmptyTest()
        {
            Assert.That(RecycleBin.Count, Is.EqualTo(0L));

            // Setup files to delete
            for (int i = 0; i < 5; i++)
            {
                RecycleBin.DeleteToRecycleBin(Path.GetTempFileName());
            }

            Assert.That(() => RecycleBin.Empty(false, false, false), Throws.Nothing);
            Assert.That(RecycleBin.Count, Is.EqualTo(0L));

            // Setup files to delete
            for (int i = 0; i < 5; i++)
            {
                RecycleBin.DeleteToRecycleBin(Path.GetTempFileName());
            }

            Assert.That(() => RecycleBin.Empty(), Throws.Nothing);
            Assert.That(RecycleBin.Count, Is.EqualTo(0L));
        }
        private static void Main(string[] args)
        {
            RecycleBin.Empty();

            var cancel = 0;

            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                eventArgs.Cancel = true;
                Interlocked.Increment(ref cancel);
            };

            var ntfsCompress = new NtfsCompress(
                new DirectoryInfo("C:\\windows\\SoftwareDistribution"),
                new NtfsCompressionOptions {
                EnableCompression = true, ContinueOnError = true, Recurse = true
            });

            //ntfsCompress.Compress(ref cancel);

            Debugger.Break();
        }