详解Silverlight 2中的独立存储(Isolated Storage)
[1] 详解Silverlight 2中的独立存储(Isolated Storage)
[2] 详解Silverlight 2中的独立存储(Isolated Storage)
[3] 详解Silverlight 2中的独立存储(Isolated Storage)
[4] 详解Silverlight 2中的独立存储(Isolated Storage)
[5] 详解Silverlight 2中的独立存储(Isolated Storage)
[6] 详解Silverlight 2中的独立存储(Isolated Storage)
[7] 详解Silverlight 2中的独立存储(Isolated Storage)
[2] 详解Silverlight 2中的独立存储(Isolated Storage)
[3] 详解Silverlight 2中的独立存储(Isolated Storage)
[4] 详解Silverlight 2中的独立存储(Isolated Storage)
[5] 详解Silverlight 2中的独立存储(Isolated Storage)
[6] 详解Silverlight 2中的独立存储(Isolated Storage)
[7] 详解Silverlight 2中的独立存储(Isolated Storage)
删除目录和文件:
void btnDeleteFile_Click(object sender, RoutedEventArgs e) { if (this.lstDirectories.SelectedItem != null && this.lstFiles.SelectedItem != null) { using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { String filePath = System.IO.Path.Combine(this.lstDirectories.SelectedItem.ToString(), this.lstFiles.SelectedItem.ToString()); store.DeleteFile(filePath); HtmlPage.Window.Alert("删除文件成功!"); } } } void btnDeleteDirectory_Click(object sender, RoutedEventArgs e) { if (this.lstDirectories.SelectedItem != null) { using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { store.DeleteDirectory(this.lstDirectories.SelectedItem.ToString()); HtmlPage.Window.Alert("删除目录成功!"); } } }
获取目录列表和文件列表:
void lstDirectories_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (lstDirectories.SelectedItem != null) { using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { String[] files = store.GetFileNames( this.lstDirectories.SelectedItem.ToString() + "/"); this.lstFiles.ItemsSource = files; } } } void BindDirectories() { using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { String[] directories = store.GetDirectoryNames("*"); this.lstDirectories.ItemsSource = directories; } }