public static string[] GetFiles(string path, string searchPattern) { List <string> list = new List <string>(); PathInternal.DllImport.WIN32_FIND_DATA findData = new PathInternal.DllImport.WIN32_FIND_DATA(); IntPtr findFileHandle = PathInternal.DllImport.FindFirstFileExW(PathInternal.ConvertToUnicodePath(Path.Combine(path, searchPattern)), 0, ref findData, 0, (IntPtr)0, 0); if (findFileHandle.ToInt64() > 0) { do { if ((findData.dwFileAttributes & PathInternal.DllImport.FILE_ATTRIBUTE_DIRECTORY) == 0) { list.Add(Path.Combine(path, findData.cFileName)); } } while (PathInternal.DllImport.FindNextFile(findFileHandle, ref findData)); PathInternal.DllImport.FindClose(findFileHandle); } return(list.ToArray()); }
public static string[] GetFiles( string path, string searchPattern ) { List<string> list = new List<string>(); PathInternal.DllImport.WIN32_FIND_DATA findData = new PathInternal.DllImport.WIN32_FIND_DATA(); IntPtr findFileHandle = PathInternal.DllImport.FindFirstFileExW( PathInternal.ConvertToUnicodePath( Path.Combine( path, searchPattern ) ), 0, ref findData, 0, (IntPtr)0, 0 ); if ( findFileHandle.ToInt64() > 0 ) { do { if ( ( findData.dwFileAttributes & PathInternal.DllImport.FILE_ATTRIBUTE_DIRECTORY ) == 0 ) list.Add( Path.Combine( path, findData.cFileName ) ); } while ( PathInternal.DllImport.FindNextFile( findFileHandle, ref findData ) ); PathInternal.DllImport.FindClose( findFileHandle ); } return list.ToArray(); }