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. system.IO.File and System.IO.FileInfo slow

system.IO.File and System.IO.FileInfo slow

Scheduled Pinned Locked Moved C#
windows-adminhelpquestion
2 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.
  • R Offline
    R Offline
    Rei Miyasaka
    wrote on last edited by
    #1

    Certain IO methods, particularly FileInfo.LastWriteTime and FileInfo.Size are excruciatingly slow, especially the first time around. I know the first time around is slow because the files haven't been cached yet. But it's excruciatingly slow; for a folder of about 1000 files, the cmd.exe dir command can do it in a few seconds whereas it takes System.IO.File and System.IO.FileInfo more than 30 seconds. I noticed PowerShell has this problem too, since the ls/dir cmdlets use FileInfo as well. Any ideas on a workaround/remedy? Thanks in advance, Rei

    C 1 Reply Last reply
    0
    • R Rei Miyasaka

      Certain IO methods, particularly FileInfo.LastWriteTime and FileInfo.Size are excruciatingly slow, especially the first time around. I know the first time around is slow because the files haven't been cached yet. But it's excruciatingly slow; for a folder of about 1000 files, the cmd.exe dir command can do it in a few seconds whereas it takes System.IO.File and System.IO.FileInfo more than 30 seconds. I noticed PowerShell has this problem too, since the ls/dir cmdlets use FileInfo as well. Any ideas on a workaround/remedy? Thanks in advance, Rei

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Write the code to do it in C++, perhaps using C++/CLI so you can call it from C#.

      Christian Graus - C++ MVP

      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