本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFileStream.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFileStream.Dispose方法的具体用法?C# IsolatedStorageFileStream.Dispose怎么用?C# IsolatedStorageFileStream.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.IsolatedStorage.IsolatedStorageFileStream
的用法示例。
在下文中一共展示了IsolatedStorageFileStream.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MenuItem_Click
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
MenuItem menu = sender as MenuItem;
string strTemp = menu.Tag.ToString();
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
try
{
IsolatedStorageFileStream location;
location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.Open, storage);
StreamReader sr = new StreamReader(location);
string content = sr.ReadToEnd();
sr.Close();
location.Dispose();
content = content.Replace(strTemp, "");
location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.Truncate, storage);
StreamWriter sw = new StreamWriter(location);
sw.Write(content);
sw.Close();
location.Dispose();
}
catch (Exception e1)
{
Debug.WriteLine(e1.Message);
}
}
llsFavRoutes.ItemsSource = null;
BindData();
}
示例2: LoadClues
// this code is modfied code from the following tutorial
// http://blogs.msdn.com/b/mingfeis_code_block/archive/2010/10/03/windows-phone-7-how-to-store-data-and-pass-data-between-pages.aspx
public void LoadClues()
{
EnterClues();
string elementNumber;
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
for (int i=0; i < noClues; i++)
{
elementNumber = "number"+clueId[i].ToString();
XDocument _doc = new XDocument();
XElement _clue = new XElement(elementNumber);
XAttribute _clueId = new XAttribute("clueId", clueId[i]);
XAttribute _clueText = new XAttribute("clueText", clueText[i]);
XAttribute _barcodeRef = new XAttribute("barcodeRef", barcodeRef[i]);
XAttribute _location = new XAttribute("location", location[i]);
XAttribute _locInfo = new XAttribute("locInfo", locInfo[i]);
XAttribute _latitude = new XAttribute("latitude", latitude[i]);
XAttribute _longitude = new XAttribute("longitude", longitude[i]);
_clue.Add(_clueId, _clueText, _barcodeRef, _location, _locInfo, _latitude, _longitude);
_doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), _clue);
IsolatedStorageFileStream memory = new IsolatedStorageFileStream(elementNumber + ".clue", System.IO.FileMode.Create, storage);
System.IO.StreamWriter file = new System.IO.StreamWriter(memory);
_doc.Save(file);
file.Dispose();
memory.Dispose();
}
}
}
示例3: BindData
private void BindData()
{
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
try
{
ObservableCollection<Route> routes = new ObservableCollection<Route>();
IsolatedStorageFileStream location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.Open, storage);
StreamReader sr = new StreamReader(location);
string content = sr.ReadToEnd();
string[] strRoutes = content.Split(';');
foreach(string strTempRoute in strRoutes)
{
Route route = new Route();
string[] strRoute = strTempRoute.Split(',');
if(strRoute[0] == WebService.GetCity())
{
route.StartStat = strRoute[1];
route.EndStat = strRoute[2];
route.Info = strTempRoute + ";";
routes.Add(route);
}
}
llsFavRoutes.ItemsSource = routes;
location.Dispose();
}
catch (Exception e1)
{
Debug.WriteLine(e1.Message);
}
}
}
示例4: PhoneApplicationPage_Loaded
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
if (!storage.FileExists("LeaveSettings.xml"))
{
this.PayPeriodBase.Text = PayPeriodUtilities.GetCurrentPayPeriod().AddDays(-1).ToShortDateString();
this.AnnualBalance.Focus();
}
else
{
using (storage)
{
XElement _xml;
IsolatedStorageFileStream location = new IsolatedStorageFileStream(@"LeaveSettings.xml", System.IO.FileMode.Open, storage);
System.IO.StreamReader file = new System.IO.StreamReader(location);
_xml = XElement.Parse(file.ReadToEnd());
if (_xml.Name.LocalName != null)
{
this.AnnualBalance.Text = _xml.Attribute("AnnualBalance").Value;
this.SickBalance.Text = _xml.Attribute("SickBalance").Value;
this.AnnualAccrue.Text = _xml.Attribute("AnnualAccrue").Value;
this.SickAccrue.Text = _xml.Attribute("SickAccrue").Value;
this.PayPeriodBase.Text = _xml.Attribute("PayPeriod").Value;
}
file.Dispose();
location.Dispose();
}
}
}
示例5: CopyFromContentToStorage
private void CopyFromContentToStorage(IsolatedStorageFile ISF, String SourceFile, String DestinationFile)
{
Stream Stream = Application.GetResourceStream(new Uri(SourceFile, UriKind.Relative)).Stream;
IsolatedStorageFileStream ISFS = new IsolatedStorageFileStream(DestinationFile, System.IO.FileMode.Create, System.IO.FileAccess.Write, ISF);
CopyStream(Stream, ISFS);
ISFS.Flush();
ISFS.Close();
Stream.Close();
ISFS.Dispose();
}
示例6: Questions
public Questions() {
IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication();
questions = new List<String>();
answeres = new List<Boolean>();
if (ISF.FileExists("Questions.xml")) {
IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("Questions.xml", FileMode.Open, FileAccess.Read, FileShare.Read, ISF);
var qslist = from c in XElement.Load(isoStream).Element("Questions").Elements() // Important we are loading from ISF updated from dropbox !!
select c;
ISF.Dispose();
isoStream.Dispose();
foreach (var el in qslist)
{
this.questions.Add(el.Value);
if ((string)el.Attribute("answ") == "true")
this.answeres.Add(true);
else
this.answeres.Add(false);
}
}
else
{
ISF.Dispose();
var qslist = from c in XElement.Load("Assets/Questions.xml").Element("Questions").Elements()
select c;
foreach (var el in qslist)
{
this.questions.Add(el.Value);
if ((string)el.Attribute("answ") == "true")
this.answeres.Add(true);
else
this.answeres.Add(false);
}
}
}
示例7: Open_Click
private void Open_Click(object sender, RoutedEventArgs e)
{
if (Files.SelectedItem != null)
{
app.Filename = (string)Files.SelectedItem;
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
IsolatedStorageFileStream location = new IsolatedStorageFileStream(app.Filename,
System.IO.FileMode.Open, storage);
System.IO.StreamReader file = new System.IO.StreamReader(location);
app.Content = file.ReadToEnd();
file.Dispose();
location.Dispose();
}
NavigationService.GoBack();
}
}
示例8: ws_GetThongBaoDonCompleted
void ws_GetThongBaoDonCompleted(object sender, GetThongBaoDonCompletedEventArgs e)
{
if (e.Result != "")
{
//Load thong bao len RichEidit
IsolatedStorageFileStream fs = new IsolatedStorageFileStream("Temp.doc", FileMode.OpenOrCreate, FileAccess.ReadWrite, str);
BinaryWriter br = new BinaryWriter(fs);
br.Write(Convert.FromBase64String(e.Result));
richEdit.LoadDocument(fs, DocumentFormat.Doc);
this.Title = tieude;
fs.Close();
fs.Dispose();
}
else
{
richEdit.Text = "Nội dung thông báo trống";
}
}
示例9: decode
private void decode(object sender, RoutedEventArgs e)
{
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
LibmadWrapper Libmad = new LibmadWrapper();
IBuffer buffer = WindowsRuntimeBufferExtensions.AsBuffer(Mp3bytes, 0, Mp3bytes.Length);
PCMStream = isf.CreateFile("decoded_pcm.pcm");
bool init = Libmad.DecodeMp32Pcm_Init(buffer);
if (init)
{
List<short> samples = new List<short>();
RawPCMContent rpcc = null;
try
{
while ((rpcc = Libmad.ReadSample()).count != 0)
{
short[] shortBytes = rpcc.PCMData.ToArray<short>();
byte[] rawbytes = new byte[shortBytes.Length * 2];
for (int i = 0; i < shortBytes.Length; i++)
{
rawbytes[2 * i] = (byte)shortBytes[i];
rawbytes[2 * i + 1] = (byte)(shortBytes[i] >> 8);
}
PCMStream.Write(rawbytes, 0, rawbytes.Length);
}
PCMStream.Flush();
PCMStream.Close();
PCMStream.Dispose();
MessageBox.Show("over");
Libmad.CloseFile();
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
isf.Dispose();
}
示例10: GetCurrentLeaveEntries
public static Collection<LeaveEntry> GetCurrentLeaveEntries()
{
IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
if (storage.FileExists("LeaveRecords.xml"))
{
IsolatedStorageFileStream location = new IsolatedStorageFileStream("LeaveRecords.xml", System.IO.FileMode.Open, storage);
System.IO.StreamReader file = new System.IO.StreamReader(location);
XmlSerializer serializer = new XmlSerializer(typeof(Collection<LeaveEntry>));
Collection<LeaveEntry> entries = (Collection<LeaveEntry>)serializer.Deserialize(file);
file.Dispose();
location.Dispose();
return entries;
}
else
{
return new Collection<LeaveEntry>();
}
}
示例11: PorpAllSourcesToDb
public void PorpAllSourcesToDb(ICollection<FeedSource> allFeedSources)
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
var stream = new IsolatedStorageFileStream("test.txt",
System.IO.FileMode.Create,
System.IO.FileAccess.Write,
store);
try
{
FeedSourceCollection allSourcesCollection = new FeedSourceCollection();
allSourcesCollection.Items = new List<FeedSource>(allFeedSources);
XmlSerializer serializer = new XmlSerializer(typeof(FeedSourceCollection));
serializer.Serialize(stream, allSourcesCollection);
}
finally
{
stream.Close();
stream.Dispose();
}
}
}
示例12: ApplicationBarIconButton_Click
private void ApplicationBarIconButton_Click(object sender, EventArgs e)
{
System.IO.IsolatedStorage.IsolatedStorageFile storage = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
using (storage)
{
XDocument _doc = new XDocument();
XElement baseSetting = new XElement("BaseSetting");
XAttribute AnnualBalance = new XAttribute("AnnualBalance", this.AnnualBalance.Text);
XAttribute SickBalance = new XAttribute("SickBalance", this.SickBalance.Text);
XAttribute AnnualAccrue = new XAttribute("AnnualAccrue", this.AnnualAccrue.Text);
XAttribute SickAccrue = new XAttribute("SickAccrue", this.SickAccrue.Text);
XAttribute PayPeriod = new XAttribute("PayPeriod", this.PayPeriodBase.Text);
baseSetting.Add(AnnualBalance, SickBalance, AnnualAccrue, SickAccrue, PayPeriod);
_doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), baseSetting);
IsolatedStorageFileStream location = new IsolatedStorageFileStream("LeaveSettings.xml", FileMode.Create, storage);
StreamWriter file = new StreamWriter(location);
_doc.Save(file);
file.Dispose();
location.Dispose();
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}
}
示例13: GetBaseValues
public static Basis GetBaseValues()
{
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
Basis baseValues = new Basis();
XElement _xml;
IsolatedStorageFileStream location = new IsolatedStorageFileStream(@"LeaveSettings.xml", System.IO.FileMode.Open, storage);
System.IO.StreamReader file = new System.IO.StreamReader(location);
_xml = XElement.Parse(file.ReadToEnd());
if (_xml.Name.LocalName != null)
{
baseValues.StartingAnnual = double.Parse(_xml.Attribute("AnnualBalance").Value);
baseValues.StartingSick = double.Parse(_xml.Attribute("SickBalance").Value);
baseValues.AnnualAccrue = double.Parse(_xml.Attribute("AnnualAccrue").Value);
baseValues.SickAccrue = double.Parse(_xml.Attribute("SickAccrue").Value);
baseValues.StartingPayPeriod = DateTime.Parse(_xml.Attribute("PayPeriod").Value);
}
file.Dispose();
location.Dispose();
return baseValues;
}
}
示例14: LoadDataFromStore
private void LoadDataFromStore()
{
IsolatedStorageFileStream isStream = null;
try
{
lock (store)
{
isStream = new IsolatedStorageFileStream(storageAreaName + @"\" + itemsFileName, FileMode.Open, FileAccess.Read, FileShare.None, store);
using (StreamReader reader = new StreamReader(isStream))
{
if (!reader.EndOfStream)
{
items = (List<ItemModel>)serializer.Deserialize(reader);
}
} // this should implicitly dispose of isStream too
}
}
catch (Exception)
{
}
finally
{
if (items == null)
items = new List<ItemModel>();
if (isStream != null)
isStream.Dispose();
}
}
示例15: appBarBtnFav_Click
private void appBarBtnFav_Click(object sender, System.EventArgs e)
{
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
try
{
IsolatedStorageFileStream location;
if (!storage.FileExists("favoriteRoutes.dat"))
{
location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.CreateNew, storage);
location.Dispose();
}
location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.Open, storage);
string strTemp = WebService.GetCity() + "," + m_strStart + "," + m_strEnd + ";";
StreamReader sr = new StreamReader(location);
string content = sr.ReadToEnd();
sr.Close();
location.Dispose();
if (content.Contains(strTemp))
{
MessageBox.Show("已收藏");
}
else
{
location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.Append, storage);
StreamWriter sw = new StreamWriter(location);
sw.Write(strTemp);
sw.Close();
MessageBox.Show("收藏成功");
location.Dispose();
}
}
catch (Exception e1)
{
Debug.WriteLine(e1.Message);
}
}
}