-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 except the folder. The folder has Fixed name, does not vary.
I did this and says that it is not possible to convert char to string[]. The var files is a string array.
private void button1_Click(object sender, EventArgs e)
{
string[] result = Path.GetFileNameWithoutExtension(arquivos.ToString());
}
All I need is to bring the name of the files and without the path of the files.
This way here, solved:
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);
}
}
It didn’t work because
arquivos
in my context is files and need to delete folders.– pnet
True. Try using
StartsWith()
, shall produce the expected effect.– Jéf Bueno