Csharp/C Sharp/File Stream/IsolatedStorageFile

Материал из .Net Framework эксперт
Версия от 11:45, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

CurrentSize and Scope

 
using System;
using System.IO;
using System.IO.IsolatedStorage;
class MainClass {
    static void Main(string[] args) {
        using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForAssembly()) {
            store.CreateDirectory("MyFolder");
            using (Stream fs = new IsolatedStorageFileStream("MyFile.txt", FileMode.Create, store)) {
                StreamWriter w = new StreamWriter(fs);
                w.WriteLine("Test");
                w.Flush();
            }
            Console.WriteLine("Current size: " + store.CurrentSize.ToString());
            Console.WriteLine("Scope: " + store.Scope.ToString());
            Console.WriteLine("Contained files include:");
            string[] files = store.GetFileNames("*.*");
            foreach (string file in files) {
                Console.WriteLine(file);
            }
        }
    }
}


GetFileNames, CreateDirectory, GetUserStoreForAssembly

 
using System;
using System.IO;
using System.IO.IsolatedStorage;
class MainClass {
    static void Main(string[] args) {
        using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForAssembly()) {
            store.CreateDirectory("MyFolder");
            using (Stream fs = new IsolatedStorageFileStream("MyFile.txt", FileMode.Create, store)) {
                StreamWriter w = new StreamWriter(fs);
                w.WriteLine("Test");
                w.Flush();
            }
            Console.WriteLine("Current size: " + store.CurrentSize.ToString());
            Console.WriteLine("Scope: " + store.Scope.ToString());
            Console.WriteLine("Contained files include:");
            string[] files = store.GetFileNames("*.*");
            foreach (string file in files) {
                Console.WriteLine(file);
            }
        }
    }
}