Find file in multiple folders from a home folder, except the folder

-2
string[] arquivos = Directory.GetFiles(@"C:\Teste_Zip\web", "*", SearchOption.AllDirectories);

The question is: I need to get the files, except in a folder. I could not get past the folder. The folder is Fixed, does not vary.

I did this and says that it is not possible to convert char to string []. The var files is an array of string.

private void button1_Click(object sender, EventArgs e)
        {
            string[] result = Path.GetFileNameWithoutExtension(arquivos.ToString());

        }

All I need is to get the name of the files and the path of the files.

Here's how you solved it:

private void button1_Click(object sender, EventArgs e)
        {
            string s = string.Empty;
            List<string> lista = new List<string>();

            string path = ConfigurationSettings.AppSettings["Caminho_Base"];

            string[] arquivos = Directory.GetFiles(path, "*", SearchOption.AllDirectories);

            foreach(var item in arquivos)
            {
                s = Path.GetFileNameWithoutExtension(item);
                if (!item.Contains("TSNMVC"))
                    lista.Add(s);
            }

        }
    
asked by anonymous 29.02.2016 / 20:00

2 answers

0

Just setting the jbueno code I believe works for what you need.

var files = Directory.GetFiles(@"C:\Teste_Zip\web", "*.*", SearchOption.AllDirectories)
.Where(d => !d.Contains("C:\Teste_Zip\PASTA_A_EXCLUIR")).ToArray();
    
29.02.2016 / 21:38
0

Make a condition using LINQ

var arquivos = Directory.GetFiles(@"C:\Teste_Zip\web", "*", SearchOption.AllDirectories)
.Where(x => x.StartsWith("Nome da pasta a excluir")).ToArray();
    
29.02.2016 / 20:07