我不是一個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代替。
嗨keyboardP。首先,請允許我表示感謝您的快速回復。你說我需要使用'GetFileName()'的模式來獲取子目錄文件。 Dim file As String()= storeFile.GetFileNames(pattern)'。首先,我寫了文件(「database/test.txt」),然後檢查了'.Exists = True',現在我仍然無法使用GetFileNames方法(GetFileNames(「datbase /」))列出文件。 WP7文件瀏覽器顯示該文件,有什麼建議? – Nasenbaer 2012-01-15 07:58:46
嗨keyboardP。再次感謝。因爲你的例子,我用'*'得到了訣竅。非常感謝...你做了我的一天:-) – Nasenbaer 2012-01-15 08:57:15
不客氣: )'*'是通配符,因此它將匹配所有內容。 – keyboardP 2012-01-15 13:53:08