Checking if folder has files

前端 未结 6 1121
清歌不尽
清歌不尽 2021-02-10 09:58

I have program which writes to database which folders are full or empty. Now I\'m using

bool hasFiles=false;
(Directory.GetFiles(path).Length >0) ? hasFiles=         


        
6条回答
  •  闹比i
    闹比i (楼主)
    2021-02-10 10:21

    Might be worth mentioning:

    but it takes almost one hour, and I can't do anything in this time. (emphasis added)

    Are you doing this from a GUI app, on the main thread? If so, spit this process off using a BackgroundWorker. At least then the app will continue to be responsive. You could also add checks for CancellationPending in the method and cancel it if it's taking too long.

    Kind of tangential to your question--just something I noticed and thought I'd comment on.

提交回复
热议问题