Hi,
Could you maybe help me out with some code to scan folders and subfolders for files?PLEASE...
I cant find any useful information on the net..
All i wanna do is search a selected folder with its subfolders for a specific file types and then rename those found files extension to for example .rar files...
Any help would be greatly appreciated.... :-)
Thanks
Regards

wow thanks now that helps...i know i have to use that but i dont know how...anyway il try to find a different forum for help not that there really are any...
regards

Hi, is this what you want, I threw it together real quick, but you should be able to finish the rest, this will get you started.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace filetest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            scanDir("C:\\", 1);
        }

        const int HowDeepToScan = 7;

        private static void prcoessdire(string sourceDir, int recursionLvl)
        {
            scanDir(sourceDir, recursionLvl);
        }

        private static void scanDir(string sourceDir, int recursionLvl)
        {
            if (recursionLvl <= HowDeepToScan)
            {
                // Process the list of files found in the directory.
                string[] fileEntries = Directory.GetFiles(sourceDir);
                foreach (string fileName in fileEntries)
                {
                    MessageBox.Show(fileName);
                }

                // Recurse into subdirectories of this directory.
                string[] subdirEntries = Directory.GetDirectories(sourceDir);
                foreach (string subdir in subdirEntries)
                    // Do not iterate through reparse points
                    if ((File.GetAttributes(subdir) &
                         FileAttributes.ReparsePoint) !=
                             FileAttributes.ReparsePoint)

                        scanDir(subdir, recursionLvl + 1);
            }
        }
    }
}

This is just the basic concet of it....

This article has been dead for over six months. Start a new discussion instead.