Error using File.Delete method within Controller

Asked

Viewed 362 times

7

I’m in trouble in my controller the moment I start a file deletion routine.

I am using the method File.Delete(), but he simply does not recognize and returns me the following warning:

Cannot Choose method from method group. Did you intend to invoke the method?

Follow the code too:

public void Delete(String id)
{
    //Função que busca o meu arquivo de delete
    var modelArquivo = BuscaArquivo(id);

    //Aqui se atribue o nome completo do arquivo
    var nomeArquivo = modelArquivo.NomeArquivoCompleto;

    //Aqui da-se a advertência citada acima
    File.Delete(nomeArquivo);         
}

Any idea what’s going on?

2 answers

10

Have you tried using instead of

//Aqui da-se a advertência citada acima
File.Delete(nomeArquivo); 

Use

System.IO.File.Delete(nomeArquivo)

7


It seems to me conflict of namespace. You could test with:

System.IO.File.Delete(nomeArquivo)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.