I have a screen where listo files of a certain folder. I have a search bar that uses the same method to find the files, but I can not list by approximation. Example:
I have this file Papel_timbrado.docx
.
If I search "Paper" I find the file, however if I search "Letterhead" my search returns blank. is there any way to find the files by approximation?
I'm using the System.IO
class to find the files ( GetFiles
)
public void PopulaLista(string arquivo, string extensao)
{
string resposta = "<table class=\"table table-striped table-bordered table_qr\" id=\"sample_1\" runat=\"server\">";
DirectoryInfo diretorio = new DirectoryInfo(objUtils.Diretorio("upload/pastamateriais/"));
if (string.IsNullOrWhiteSpace(arquivo) == true) { arquivo = "*"; }
FileInfo[] Arquivos = diretorio.GetFiles(arquivo + extensao);
resposta += " <thead>";
resposta += " <tr>";
resposta += " <th>Nome do Arquivo</th>";
resposta += " <th>Tipo</th>";
resposta += " <th>Tamanho</th>";
resposta += " <th style=\"width:70px;\">Ações</th>";
resposta += " </tr>";
resposta += " </thead>";
resposta += " <tbody>";
TextInfo myTI = new CultureInfo("en-US", false).TextInfo;
foreach (FileInfo fileinfos in Arquivos)
{
if (fileinfos.Name != "Thumbs.db")
{
resposta += " <tr>";
resposta += " <td>" + myTI.ToTitleCase(fileinfos.Name.Replace(fileinfos.Extension, "").Replace("_", " ").Replace("-"," ")) + "</td>";
resposta += " <td><img alt='" + fileinfos.Extension + "' src='images/icon-" + fileinfos.Extension.Replace(".", "") + ".png' /></td>";
resposta += " <td>" + Convert.ToDecimal(fileinfos.Length / 1024) + " KB</td>";
resposta += " <td><a href=upload/pastamateriais/" + fileinfos.Name + " class=\"img_edit\" download><img src=\"images/download.png\" /></a><a id='" + fileinfos.Name + "' href=\"javascript:void(0)\" onclick='apagar(this.id);' class=\"img_del\"><img src=\"images/lixo.png\" /></a></td>";
resposta += " </tr>";
}
}
resposta += " </tbody>";
resposta += "</table>";
if (Request["acao"] == "Pesquisar")
{
Response.Write(resposta);
}
else
{
divLista.InnerHtml = resposta;
}
}