VB.Net Tutorial/Stream File/IsolatedStorageFile — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:56, 26 мая 2010
Содержание
Create IsolatedStorageFile
Imports System.IO.IsolatedStorage
Public Class Tester
Public Shared Sub Main
Dim myIsoStore As IsolatedStorageFile
Dim myISS As IsolatedStorageScope
Try
myISS = IsolatedStorageScope.Domain Or IsolatedStorageScope.Assembly Or IsolatedStorageScope.User
myIsoStore = IsolatedStorageFile.GetStore(myISS, Nothing, Nothing)
Catch ex As IsolatedStorageException
Console.WriteLine(ex.Message)
End Try
End Sub
End Class
Create IsolatedStorageFileStream
Imports System.IO.IsolatedStorage
Public Class Tester
Public Shared Sub Main
Dim myIsoStore As IsolatedStorageFile
Try
myIsoStore.CreateDirectory("newDir")
Dim myIsoStroeStream As New IsolatedStorageFileStream("test.txt", IO.FileMode.Create.Create, myIsoStore)
myIsoStroeStream.Close()
Catch ex As IsolatedStorageException
Console.WriteLine(ex.Message)
End Try
End Sub
End Class
Get Directory and Files in an IsolatedStorageFile
Imports System.IO.IsolatedStorage
Public Class Tester
Public Shared Sub Main
Dim strFile As String
Dim strDir As String
Dim myIsoStore As IsolatedStorageFile
Try
For Each strDir In myIsoStore.GetDirectoryNames("*")
Console.WriteLine(strDir)
For Each strFile In myIsoStore.GetFileNames(strDir + "/*.*")
Console.WriteLine(strFile)
Next
Next
Catch ex As IsolatedStorageException
Console.WriteLine(ex.Message)
End Try
End Sub
End Class
Use IsolatedStorageFile.DeleteFile, DeleteDirectory
Imports System.IO.IsolatedStorage
Public Class Tester
Public Shared Sub Main
Dim myIsoStore As IsolatedStorageFile
Try
myIsoStore.CreateDirectory("oldDir")
Dim myIsoStroeStream As New IsolatedStorageFileStream("oldDir/oldFile", IO.FileMode.Create.Create, myIsoStore)
myIsoStroeStream.Close()
myIsoStore.DeleteDirectory("oldDir")
myIsoStore.DeleteFile("oldeDir/oldFile")
Catch ex As IsolatedStorageException
Console.WriteLine(ex.Message)
End Try
End Sub
End Class