Using another path to pull files from a folder outside DirectoryInfo

0

My project is running perfectly, but I would like to replace this path DirectoryInfo with another one that pulls itself straight from the folder without needing to use my directory.

Code:

public List<Arquivos> GetArquivos()
{

    List<Arquivos> lstArquivos = new List<Arquivos>();
    //DirectoryInfo dirInfo = new DirectoryInfo(HostingEnvironment.MapPath("~/Arquivos"));
    DirectoryInfo dirInfo = new DirectoryInfo("C:/Users/Usuario/source/repos/FEESC/FEESC/UploadedFiles");
    int i = 0;
    foreach (var item in dirInfo.GetFiles())
    {
        lstArquivos.Add(new Arquivos()
        {
            arquivoID = i + 1,
            arquivoNome = item.Name,
            arquivoCaminho = dirInfo.FullName + @"\" + item.Name
        });
        i = i + 1;
    }
    return lstArquivos;
}
    
asked by anonymous 26.08.2017 / 00:53

1 answer

0

try this:

System.Web.HttpContext.Current.Server.MapPath("~/Arquivos/");

DirectoryInfo dirInfo = new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath("~/Arquivos/"));
    
26.08.2017 / 06:24