Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C# - Dateien Mit "Jokerzeichen" löschen

Empfohlene Antworten

Veröffentlicht

Mahlzeit miteinander.

Ich hab folgendes Problem: und zwar muss ich alle dateien mit einer bestimmten dateiendung ( zb. *.bat) löschen. Gibt es in C# eine möglichkeit dies zu erledigen? Der file.delete befehl unterstützt das jokerzeichen "*" nicht.

Bin um jede konstruktive hilfe dankbar

eine schleife sollte dein problem lösen ;)

DirectoryInfo für deine Datein und foreach alle files, dann löschen

danke, werds gleich mal ausprobieren

DirectoryInfo di = new DirectoryInfo(s_PLC);

                    foreach (DirectoryInfo info in di)

                    {

                        ....

                    }

kann es sein, das da was an der schleife falsch ist? weil ich bekomme folgenden fehler: Error 1 foreach statement cannot operate on variables of type 'System.IO.DirectoryInfo' because 'System.IO.DirectoryInfo' does not contain a public definition for 'GetEnumerator'

Ja sollte foreach FileInfo in dir.Files oder so sein ;)


DirectoryInfo dir = new DirectoryInfo("c:\\thepath");

foreach(FileInfo file in dir.GetFiles("*.bat")) {

  try {

    file.Delete();

  }

  catch (blub) {

    //Exception abfangen

  }

}

So aus dem Gedächnis...

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.