Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. .GetFiles(?)

.GetFiles(?)

Scheduled Pinned Locked Moved C#
csharpregexquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HahnTech
    wrote on last edited by
    #1

    Hello, what i have is this foreach( FileInfo f in di.GetFiles("*.txt")) { //do something } foreach( FileInfo f in di.GetFiles("*.log")) { //do the same thing } what i wan't is this foreach( FileInfo f in di.GetFiles("*.txt, *.log")) { //do something } but di.GetFiles("*.txt, *.log") returns nothing. can i put in a RegEx or something?

    Ronald Hahn, CNT - Computer Engineering Technologist New Technologies Analyst HahnTech Affiliated With Code Constructors Edmonton, Alberta, Canada Email: rhahn82@telus.net

    D 1 Reply Last reply
    0
    • H HahnTech

      Hello, what i have is this foreach( FileInfo f in di.GetFiles("*.txt")) { //do something } foreach( FileInfo f in di.GetFiles("*.log")) { //do the same thing } what i wan't is this foreach( FileInfo f in di.GetFiles("*.txt, *.log")) { //do something } but di.GetFiles("*.txt, *.log") returns nothing. can i put in a RegEx or something?

      Ronald Hahn, CNT - Computer Engineering Technologist New Technologies Analyst HahnTech Affiliated With Code Constructors Edmonton, Alberta, Canada Email: rhahn82@telus.net

      D Offline
      D Offline
      Dustin Metzgar
      wrote on last edited by
      #2

      Nope, you're pretty limited in this regard. Maybe an alternative is to pair up the collections:

      List lst = new List();
      lst.AddRange(di.GetFiles("*.txt"));
      lst.AddRange(di.GetFiles("*.log"));
      foreach (FileInfo fi in lst) { ... }

      If you want them to be in a particular order, then you can just call Sort().


      Logifusion[^]

      H 1 Reply Last reply
      0
      • D Dustin Metzgar

        Nope, you're pretty limited in this regard. Maybe an alternative is to pair up the collections:

        List lst = new List();
        lst.AddRange(di.GetFiles("*.txt"));
        lst.AddRange(di.GetFiles("*.log"));
        foreach (FileInfo fi in lst) { ... }

        If you want them to be in a particular order, then you can just call Sort().


        Logifusion[^]

        H Offline
        H Offline
        HahnTech
        wrote on last edited by
        #3

        Setteled on this foreach( string f in Directory.GetFiles(_ControleFileBucket)) { if( f.EndsWith("*." + CDoc.EmailCF) || f.EndsWith("*." + CDoc.FaxCF)||f.EndsWith("*." + CDoc.GMailCF)) { ...

        Ronald Hahn, CNT - Computer Engineering Technologist New Technologies Analyst HahnTech Affiliated With Code Constructors Edmonton, Alberta, Canada Email: rhahn82@telus.net

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups