我想在istostorage
的子目录中列出所有文件Public Function GetAllFilesInDirectory(ByVal DirectoryName As String) As List(Of String)
Dim isoStore As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
Dim L As New List(Of String)
For Each di As String In isoStore.GetDirectoryNames
If di = DirectoryName Or di & "/" = DirectoryName Then
For Each fi As String In isoStore.GetFileNames'<-- fails because not the subdirectory is listed
If fi.StartsWith(DirectoryName) Then L.Add(fi)
Next
End If
Next
Return L
End Function
答案 0 :(得分:1)
我不是VB.NET开发人员,因此我使用转换器从我的old C# version转换。看看这是否有助于阅读所有目录:
Public Shared Sub GetIsolatedStorageView(pattern As String, storeFile As IsolatedStorageFile)
Dim root As String = System.IO.Path.GetDirectoryName(pattern)
If root <> "" Then
root += "/"
End If
Dim directories As String() = storeFile.GetDirectoryNames(pattern)
'if the root directory has no FOLDERS, then the GetFiles() method won't be called.
'the line below calls the GetFiles() method in this event so files are displayed
'even if there are no folders
If directories.Length = 0 Then
GetFiles(root, "*", storeFile)
End If
For i As Integer = 0 To directories.Length - 1
Dim dir As String = directories(i) + "/"
'Write to output window
Debug.WriteLine(root + directories(i))
'Get all the files from this directory
GetFiles(root + directories(i), pattern, storeFile)
'Continue to get the next directory
GetIsolatedStorageView(root + dir + "*", storeFile)
Next
End Sub
Private Shared Sub GetFiles(dir As String, pattern As String, storeFile As IsolatedStorageFile)
Dim fileString As String = System.IO.Path.GetFileName(pattern)
Dim files As String() = storeFile.GetFileNames(pattern)
Try
For i As Integer = 0 To storeFile.GetFileNames(dir + "/" + fileString).Length - 1
'Files are prefixed with "--"
Debug.WriteLine("--" + dir + "/" + storeFile.GetFileNames(dir + "/" + fileString)(i))
Next
Catch ise As IsolatedStorageException
Debug.WriteLine("An IsolatedStorageException exception has occurred: " + ise.InnerException)
Catch e As Exception
Debug.WriteLine("An exception has occurred: " + e.InnerException)
End Try
End Sub
如果您希望将其用于开发目的,则可以改为使用wp7explorer tool。