C# Get Hidden Files In A Directory
This example list all hidden files on the specified path.
//Suppose we have this sample directory and files //C:\TestDirectory\Files\file1.txt //C:\TestDirectory\Files\file2.txt //Hidden //C:\TestDirectory\Files\file3.txt //C:\TestDirectory\Files\file4.txt //Hidden //C:\TestDirectory\Files\file5.txt string filePaths = Directory.EnumerateFiles(@"C:\TestDirectory\Files\"). Where(f => (new FileInfo(f).Attributes & FileAttributes.Hidden) == FileAttributes.Hidden). ToArray(); foreach (string file in filePaths) Console.WriteLine(file); //Output: //C:\TestDirectory\Files\file2.txt //C:\TestDirectory\Files\file4.txt
Hello thanks for sharing the information.
I am a newbie computer programming student and have a lab work. Whatever I need to move a folder with all the sub folders and files to a target path. I could not accomplish, can you help me.
Thanks in advance.
You can use “Move” method in System.IO.Directory class.