3
No result in my post, i would like to know how the function would be used Directory.GetFiles
, to list the files and folders within it without showing the full path.
Ex:
public List Listar(String a){
return Directory.GetFiles(a, "* .*").ToList();
}
Static void Main(string[] args){ var list = List(@"C: Windows Inf"); foreach(string a in list){ Console.Writeline(a); } Console.Readline(); Console.Exit(); }
In that context it should return instead of C: Windows Inf.inf file return only the file: \inf file. the same would be with folders.
Ex: There is a folder named after file clerk he would return instead of C: Windows Inf arquivos0\ only \files\
OBS: I was told the following: Execute:
var arquivos = Directory.EnumerateFiles("C:\Windows\Inf", "*",
SearchOption.AllDirectories).Select(Path.GetFileName);
but I want to run this code and Visual C# 2008/2010 says the reference:
Directory.EnumerateFiles
does not exist as I only use version 4.0 of Microsoft . NET Framework
Sorry but not understood the question, do you want to recover only the file name? name of the files of a particular folder?
– Dorathoto
The method Directory.Enumeratefiles exists in . Net 4.0. You must reference the mscorlib Assembly and declare
using System.IO;
– ramaral
Ah yes! so I can’t see the
Directory.EnumerateFiles
. I thought this function applied to . NET 3.5 Thank you @ramaral– FRNathan13