void btnCreateDirectory_Click(object sender, RoutedEventArgs e) { using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { String directoryName = this.txtDirectoryName.Text; if (this.lstDirectories.SelectedItem != null) { directoryName = System.IO.Path.Combine(this.lstDirectories.SelectedItem.ToString(), directoryName); } if (!store.DirectoryExists(directoryName)) { store.CreateDirectory(directoryName); HtmlPage.Window.Alert("建立目錄成功!"); } } }
void btnCreateFile_Click(object sender, RoutedEventArgs e) { if (this.lstDirectories.SelectedItem == null && this.txtDirectoryName.Text == "") { HtmlPage.Window.Alert("請先選擇一個目錄或者輸入目錄名"); return; } using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { String filePath; if (this.lstDirectories.SelectedItem == null) { filePath = System.IO.Path.Combine(this.txtDirectoryName.Text, this.txtFileName.Text + ".txt"); } else { filePath = System.IO.Path.Combine(this.lstDirectories.SelectedItem.ToString(), this.txtFileName.Text + ".txt"); } IsolatedStorageFileStream fileStream = store.CreateFile(filePath); using (StreamWriter sw = new StreamWriter(fileStream)) { sw.WriteLine(this.txtFileContent.Text); } fileStream.Close(); HtmlPage.Window.Alert("寫入文件成功!"); } }
void btnReadFile_Click(object sender, RoutedEventArgs e) { if (this.lstDirectories.SelectedItem == null || this.lstFiles.SelectedItem == null) { HtmlPage.Window.Alert("請先選擇目錄和文件!"); return; } using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { String filePath = System.IO.Path.Combine(this.lstDirectories.SelectedItem.ToString(), this.lstFiles.SelectedItem.ToString()); if (store.FileExists(filePath)) { StreamReader reader = new StreamReader(store.OpenFile(filePath, FileMode.Open, FileAccess.Read)); this.txtFileContent.Text = reader.ReadToEnd(); this.txtDirectoryName.Text = this.lstDirectories.SelectedItem.ToString(); this.txtFileName.Text = this.lstFiles.SelectedItem.ToString(); } } }
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; } }
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { long newQuetaSize = 5242880; long curAvail = store.AvailableFreeSpace; if (curAvail < newQuetaSize) { store.IncreaseQuotaTo(newQuetaSize); } }
IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings; appSettings.Add("mykey","myValue"); appSettings.Save(); IsolatedStorageSettings siteSettings = IsolatedStorageSettings.SiteSettings; siteSettings.Add("mykey1","myValue1"); siteSettings.Save();
<ArrayOfKeyValueOfstringanyType xmlns:i="[url]http://www.w3.org/2001/XMLSchema-instance[/url]" xmlns="[url]http://schemas.microsoft.com/2003/10/Serialization/Arrays[/url]"> <KeyValueOfstringanyType> <Key>mykey</Key> <Value xmlns:d3p1="[url]http://www.w3.org/2001/XMLSchema[/url]" i:type="d3p1:string">myValue</Value> </KeyValueOfstringanyType> </ArrayOfKeyValueOfstringanyType>
0javascript
收藏java
Ctrl+Enter 發佈linux
發佈git
取消windows