if (Fubrowse.HasFile)
{
string path = Path.GetFullPath(Fubrowse.PostedFile.FileName);
//string root = Path.GetPathRoot(path);
GetFilesFromDirectory(path.Substring(0, path.LastIndexOf("\\")));
}
else
GeneralClass.ShowMessageBox("Please Select File First.");
}
private void GetFilesFromDirectory(string DirPath)
{
try
{
DirectoryInfo Dir = new DirectoryInfo(DirPath);
FileInfo[] FileList = Dir.GetFiles("*.cs", SearchOption.AllDirectories);
foreach (FileInfo FI in FileList)
在这里,路径是c:\windows\system32\inetsrv\config\
。我想在FileList
数组中获取所有子目录的文件名。
我遇到过同样的问题。我无法从C:\Windows\system32\intesrv\config
获取文件,因为我的系统是64位,我的请求重定向到C:\Windows\SysWOW64\system32\intesrv\config
更多解释由this answer给出。
PS。我的答案留给了那些将来会搜索的人
运行代码的Windows帐户需要对该文件夹的读访问权(通常需要管理员权限)。