12 Tem

Empty The Recycle Bin Using C#

This example shows how to empty the recycle bin using C#. First we will need to define the following function that will be empty the recycle bin:

        [DllImport("Shell32.dll", CharSet = CharSet.Unicode)]
        static extern uint SHEmptyRecycleBin (IntPtr hwnd, string pszRootPath, RecycleFlags dwFlags);
        
        public enum RecycleFlags : uint
        {
            SHERB_NOCONFIRMATION = 0x00000001,
            SHERB_NOPROGRESSUI = 0x00000002,
            SHERB_NOSOUND = 0x00000004
        }

Usage:

uint result = SHEmptyRecycleBin(IntPtr.Zero, null, RecycleFlags.SHERB_NOCONFIRMATION);

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir


altı − 1 =