Nasıl yapılır: Yalıtılmış Depolama için Depoları Numaralandırma
Statik yöntemi kullanarak IsolatedStorageFile.GetEnumerator geçerli kullanıcı için tüm yalıtılmış depoları numaralandırabilirsiniz. Bu yöntem bir IsolatedStorageScope değer alır ve bir IsolatedStorageFile numaralandırıcı döndürür. Depoları numaralandırmak için değeri belirten izne IsolatedStorageFilePermissionAdministerIsolatedStorageByUser sahip olmanız gerekir. yöntemini değeriyle User çağırırsanızGetEnumerator, geçerli kullanıcı için tanımlanan bir nesne dizisi IsolatedStorageFile döndürür.
Örnek
Aşağıdaki kod örneği kullanıcı ve derleme tarafından yalıtılmış bir depo alır, birkaç dosya oluşturur ve yöntemini kullanarak GetEnumerator bu dosyaları alır.
using System;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections;
public class EnumeratingStores
{
public static void Main()
{
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null))
{
isoStore.CreateFile("TestFileA.Txt");
isoStore.CreateFile("TestFileB.Txt");
isoStore.CreateFile("TestFileC.Txt");
isoStore.CreateFile("TestFileD.Txt");
}
IEnumerator allFiles = IsolatedStorageFile.GetEnumerator(IsolatedStorageScope.User);
long totalsize = 0;
while (allFiles.MoveNext())
{
IsolatedStorageFile storeFile = (IsolatedStorageFile)allFiles.Current;
totalsize += (long)storeFile.UsedSize;
}
Console.WriteLine("The total size = " + totalsize);
}
}
Imports System.IO
Imports System.IO.IsolatedStorage
Module Module1
Sub Main()
Using isoStore As IsolatedStorageFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User Or IsolatedStorageScope.Assembly, Nothing, Nothing)
isoStore.CreateFile("TestFileA.Txt")
isoStore.CreateFile("TestFileB.Txt")
isoStore.CreateFile("TestFileC.Txt")
isoStore.CreateFile("TestFileD.Txt")
End Using
Dim allFiles As IEnumerator = IsolatedStorageFile.GetEnumerator(IsolatedStorageScope.User)
Dim totalsize As Long = 0
While (allFiles.MoveNext())
Dim storeFile As IsolatedStorageFile = CType(allFiles.Current, IsolatedStorageFile)
totalsize += CType(storeFile.UsedSize, Long)
End While
Console.WriteLine("The total size = " + totalsize.ToString())
End Sub
End Module
Ayrıca bkz.
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin