22-12-16, 05:42 PM
22-12-16, 06:11 PM
تقرأ الملفات من فهرس معين علي هيئة مصفوفة و علي ما اتذكر Directory.GetFiles سوف تعود لك بالملفات علي اي فهرس
و تضيفها علي هيئة String من خلال جملة For ..... Next
و في الكود التالي ستجد بعض الافكار
و تضيفها علي هيئة String من خلال جملة For ..... Next
و في الكود التالي ستجد بعض الافكار
PHP كود :
Private Function GetAllTextFiles(path As String) As String()
Return GetFiles(path, "*.txt")
End Function
Private Function GetAllHtmlFiles(path As String) As String()
Return GetFiles(path, "*.html")
End Function
Private Function GetAllFiles(path As String) As String()
Return GetFiles(path, "*.*")
End Function
Private Function GetFiles(path As String, fileExtension As String) As String()
Dim parallel = Task.Run(Function()
Return Directory.GetFiles(path, fileExtension, SearchOption.AllDirectories)
End Function)
Try
Return parallel.Result
Catch ex As AggregateException
ex.Handle(Function(unauthorized)
' Handle an UnauthorizedAccessException
If TypeOf unauthorized Is UnauthorizedAccessException Then
MessageBox.Show("You do not have permission to access all folders in this path. See your network administrator or try another path.", "Error", MessageBoxButtons.OK)
End If
Return TypeOf unauthorized Is UnauthorizedAccessException
End Function)
End Try
Return New String() {}
End Function