Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 315435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:17:29+00:00 2026-05-12T08:17:29+00:00

I have written a program in .NET that recurses through all files of a

  • 0

I have written a program in .NET that recurses through all files of a source and destination directory and its subdirectories, compares lastwritetime and copies/deletes files to/from the destination directory based upon comparison result.

When eg. the destination directory is a directory on a removable drive (usb), I can not remove the usb drive from my pc, even after the program is closed. There are no other programs that have the usb open (eg explorer) and the program does not appear in the task list anymore.

The program works by getting DirectoryInfo for each directory and subdirectories using

DirectoryInfo dir = new DirectoryInfo(path);

I use GetFiles to get all files:

var files =dir.GetFiles();

Then a foreach loops through all files to check for filtering out some files (done manually because I want multiple patterns using RegEx).

Files that are not excluded based on regex filters, are added to a SortedList, one for source dir, and one for destination dir.

This is used by the compare function. It creates an enumerator for the source list and one for the destination list using the using pattern:

using (var srcEnum = _srcFileInfos.GetEnumerator())
{
    using (var dstEnum = _dstFileInfos.GetEnumerator())
    {
       ... // compare code
    }
}

Finally, files are copy or deleted using

 File.Copy
 File.Delete

Is there something I’m overlooking in terms of memory management, that would keep references to the usb drive even after I close the program?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:17:29+00:00Added an answer on May 12, 2026 at 8:17 am

    You may have closed the program, but check to make sure that the process has really terminated. Use Task Manager to find the process, then close it, then check with Task Manager to make sure it’s really gone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.