Results 1 to 2 of 2

Thread: [RESOLVED] Copying files smaller than XXmb

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2009
    Posts
    20

    Resolved [RESOLVED] Copying files smaller than XXmb

    How would i go about copying the contents of a drive to another location, skipping files larger than XXmb?

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Copying files smaller than XXmb

    You'll want something like this:

    Code:
    FileInfo info;
    string[] files = Directory.GetFiles(@"C:\", SearchOption.AllDirectories);
    foreach (string file in files)
    {
        info = new FileInfo(file);
        // !WARNING! - The length is in bytes. 
        if (info.Length <= (somesize))
        {
            info.CopyTo("Destination Directory", true);
        }
    }
    My Blog.

    Ryan Jones.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width