Possible Duplicate:
UnauthorizedAccessException cannot resolve Directory.GetFiles failure
This is the function im using to search the files:
public string SearchFor(string fileExtension, DirectoryInfo at)
{
string error = null;
try
{
foreach (DirectoryInfo subDir in at.GetDirectories())
{
SearchFor(fileExtension, subDir);
foreach (FileInfo f in at.GetFiles())
{
// test f.name for a match with fileExtension
// if it matches...
// yield return f.name;
if (f.Name == fileExtension)
{
return f.Name;
}
else
{
error = f.Name;
}
}
}
}
catch (UnauthorizedAccessException) { }
return error;
}
I know what to put for path when calling the function but what should i put for files ? How to use/call the function ? Im not sure what to put as for files .