Entwickler-Ecke

IO, XML und Registry - Papierkorb leeren


Levsen - Sa 23.02.08 16:53
Titel: Papierkorb leeren
Hallo ich möchte wissen wie man mit C# denn Papierkorb leer.

Ich möchte das wenn man auf eine Button klick [csei mir ein Bild anstatt ein Button] der Papierkorb geleert wird.

Momentan siehst bei mir so aus weis aber net weiter


C#-Quelltext
1:
2:
3:
4:
        private void trash_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("C:\\RECYCLED\\*.*");
        }


Vielen Dank im VORAUS

Moderiert von user profile iconChristian S.: B- durch C#-Tags ersetzt
Moderiert von user profile iconChristian S.: Topic aus C# - Die Sprache verschoben am Sa 23.02.2008 um 16:05


Chryzler - Sa 23.02.08 18:33

Das [http://www.pinvoke.net/default.aspx/shell32.SHEmptyRecycleBin] sollte genau das sein, was du suchst. :)


Levsen - Mo 25.02.08 17:28

das will net ganz funtzen wenn ich das rausnehme


C#-Quelltext
1:
2:
3:
4:
5:
6:
        //     No dialog box confirming the deletion of the objects will be displayed.
        const int SHERB_NOCONFIRMATION = 0x00000001;
        //     No dialog box indicating the progress will be displayed.
        const int SHERB_NOPROGRESSUI = 0x00000002;
        //     No sound will be played when the operation is complete.
        const int SHERB_NOSOUND = 0x00000004;


Was muss ich daran ändern damit das ohne Progressbar und so gezeigt wird ???


C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
    public class ShellBin
    {
        [DllImport("shell32.dll")]
        static extern int SHEmptyRecycleBin(IntPtr hWnd, string pszRootPath, uint dwFlags);

        //     No dialog box confirming the deletion of the objects will be displayed.
        const int SHERB_NOCONFIRMATION = 0x00000001;
        //     No dialog box indicating the progress will be displayed.
        const int SHERB_NOPROGRESSUI = 0x00000002;
        //     No sound will be played when the operation is complete.
        const int SHERB_NOSOUND = 0x00000004;

        public static void EmptyRecycleBin()
        {
            BinUtils.EmptyRecycleBin ( string.Empty );
        }

        public static void EmptyRecycleBin( string rootPath )
        {
            int hresult = SHEmptyRecycleBin(IntPtr.Zero, rootPath,
                    SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND);
            System.Diagnostics.Debug.Write(hresult);
        }
    }


Kha - Mo 25.02.08 22:18

user profile iconLevsen hat folgendes geschrieben:
das will net ganz funtzen wenn ich das rausnehme
Was meinst du damit :gruebel: ? So sollte der Code aber eigentlich stimmen, was passiert denn bis jetzt?


Levsen - Di 26.02.08 16:49

ich bekomme ne fehlermeldung.
Visual C# 2008 sagt mir das irgendwas mit der Progressbar is das die net da ist, wenn ich denn teil der progressbar dann rausnehme bekomme ich keine fehlermeldung aber nichts passiert beim klicken


Kha - Di 26.02.08 18:18

Fehler werden seltenst dadurch gelöst, dass man einfach Code entfernt :P . Du solltest wohl lieber (ggf. mit unserer Hilfe) versuchen, den Fehler zu korrigieren.