My problm is that I have a recursive method that given a path it enter in all the subFolders and store the file names and some info in the database.
It worked fine until I used a folder that has 31000 files and a lot of subfolders. My parameters to the method is the the path that he is working, Parent Path as a database class and a database class to perform some inserts and selects. My question is if by using the ref keyword it would help about the memory issue?

Sorry if there is an article about this. I didn't found anything.

```
public void ManageFiles(string path, Table Father, DataBaseHandlerClass DB)
{
    try
    {
        log.Info("---------------------------Inicio Pasta " + path + "--------------------------");
        DirectoryInfo d = new DirectoryInfo(path);
        DirectoryInfo[] Dirs = d.GetDirectories();
        int hashCode = path.GetHashCode();
        IFB_FilePath FilePath = DB.InsertOrUpdatePath(hashCode, path, Father == null ? null : (int?)Father.ID);

        foreach (var newPath in Dirs)
        {
            ManageFiles(newPath.FullName, FilePath, DB);
        }

        List<string> ext = DB.GetExtensionsToSearch();

        FileInfo[] Files = d.GetFiles("*.*").Where(s => ext.Contains(s.Extension.ToLower())).ToArray();
        var watch = System.Diagnostics.Stopwatch.StartNew();
        foreach (FileInfo file in Files)
        {
            watch = System.Diagnostics.Stopwatch.StartNew();
            FileTable Ficheiro = DB.InsertOrUpdateFile(file, FilePath);
            if (Ficheiro.ID_Extension_Group == 1 && !Ficheiro.Metadata.Any())
            {
                CreateFileMetadata(DB, Ficheiro);
            }
            else
            {
                if (Ficheiro.ID_Extension_Group == 1 && Ficheiro.TakenDate == null)
                {
                    UpdateTakenDate(DB, Ficheiro);
                }
            }

            watch.Stop();

            log.Info("Tempo em ms: " + watch.ElapsedMilliseconds + " Ficheiro " + file.Name);
        }
        log.Info("---------------------------Fim Pasta " + path + "--------------------------");
    }
    catch (Exception Ex)
    {
        log.Error(Ex);
    }
}

```