A folder with no name can be created by following the below
steps:
- Right-click on the folder and select Rename.
- Now press the Alt key and from the Numeric keypad, press 0160.
- Now press Enter or click anywhere on the desktop.
If you want to retrieve all the files and folders from any
directory (in C#), you would do something like this:
string path = “Path to the directory”;
DirectoryInfo di = new
DirectoryInfo(path);
foreach (DirectoryInfo
dirInfo in di.GetDirectories())
{
FileInfo[] fInfos = dirInfo.GetFiles();
// You
can easily iterate through the files here
}
But if you have any folder with a blank space as name, the above method
would give you wrong result. You would need to make few changes as shown below:
string path = “Path to the directory” + “\\”;
DirectoryInfo di = new
DirectoryInfo(path);
foreach (DirectoryInfo
dirInfo in di.GetDirectories())
{
if (dirInfo.Name == "\u00A0")
{
string fullPath = dirInfo.FullName + "\\";
dirInfo = new DirectoryInfo(fullPath);
}
FileInfo[] fInfos = dirInfo.GetFiles();
// You
can easily iterate through the files
}
No comments:
Post a Comment