Ah bummer! I just realised I'm in the C# forum. Here's the translations:
C# Code:
private void SearchComputer()
{
foreach (System.IO.DriveInfo drive in System.IO.DriveInfo.GetDrives())
{
if (drive.DriveType == System.IO.DriveType.Fixed)
{
SearchFolder(drive.Name);
}
}
}
private void SearchFolder(string folder)
{
try
{
foreach (string subfolder in System.IO.Directory.GetDirectories(folder))
{
SearchFolder(subfolder);
}
foreach (string file in System.IO.Directory.GetFiles(folder))
{
// Do whatever is appropriate here.
Console.WriteLine(file);
}
}
catch (UnauthorizedAccessException)
{
// Ignore this folder as the user doesn't have permission to access it.
}
}
C# Code:
private void SearchComputer()
{
foreach (System.IO.DriveInfo drive in System.IO.DriveInfo.GetDrives())
{
if (drive.DriveType == System.IO.DriveType.Fixed)
{
SearchFolder(drive.RootDirectory);
}
}
}
private void SearchFolder(System.IO.DirectoryInfo folder)
{
try
{
foreach (System.IO.DirectoryInfo subfolder in folder.GetDirectories())
{
SearchFolder(subfolder);
}
foreach (System.IO.FileInfo file in folder.GetFiles())
{
// Do whatever is appropriate here.
Console.WriteLine(file.FullName);
}
}
catch (UnauthorizedAccessException)
{
// Ignore this folder as the user doesn't have permission to access it.
}
}