How do I validate whether files in a directory are hidden or hidden?

Asked

Viewed 217 times

0

Good morning, Everybody.

There is a program that prints PDF files that are in a predefined directory.

The problem was happening because there were two hidden folder files and the program was trying to print and burst the error as the print below:

Erro causado por existir arquivo oculto na pasta

How do I check if file found in folder is hidden ?

  • 1

    Try to see this post, I think that’s what you need: https://stackoverflow.com/questions/39561848/how-to-check-whether-a-file-is-hidden?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

  • @Joanabrandão, thanks for the tip, I’ll look at this post.

1 answer

0


Solved the problem with the code below. Depending would not need to have created a method, however, in my case got better this way.

private Boolean IsFileHidden(string arquivo)
{
    var fileInfo = new FileInfo(arquivo);
    if (fileInfo.Attributes.HasFlag(FileAttributes.Hidden))
    {
        return true;
    }
    return false;
}

Browser other questions tagged

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