本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFileStream.Close方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFileStream.Close方法的具体用法?C# IsolatedStorageFileStream.Close怎么用?C# IsolatedStorageFileStream.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.IsolatedStorage.IsolatedStorageFileStream
的用法示例。
在下文中一共展示了IsolatedStorageFileStream.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button1_Click
private void button1_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog nekaj = new OpenFileDialog();
bool? nekaj2 = nekaj.ShowDialog();
if (nekaj2 == true)
{
using (FileStream fs = nekaj.File.OpenRead())
{
byte[] buffer = new byte[(int)fs.Length];
fs.Read(buffer, 0, (int)fs.Length);
char[] niz = new char[buffer.Length];
for (int i = 0; i < buffer.Length; i++)
niz[i] = (char)buffer[i];
IsolatedStorageFile isf =
IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream tok = new IsolatedStorageFileStream("test.txt", FileMode.Create, isf);
tok.Write(buffer, 0, buffer.Length);
tok.Close();
}
}
else MessageBox.Show("Preklicano");
}
示例2: Main
static void Main(string[] args)
{
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);
Console.WriteLine("Enter 'quit' on a blank line to exit.");
while (true)
{
string input = Console.ReadLine();
if (input == "quit")
break;
sw.WriteLine(input);
}
sw.Flush();
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly();
IsolatedStorageFileStream fs = new IsolatedStorageFileStream("output.txt", FileMode.Create, isoStore);
ms.WriteTo(fs);
sw.Close();
ms.Close();
fs.Close();
IsolatedStorageFileStream tr = new IsolatedStorageFileStream("output.txt", FileMode.Open, isoStore);
StreamReader sr = new StreamReader(tr);
Console.Write(sr.ReadToEnd());
sr.Close();
tr.Close();
}
示例3: SaveFile
public static void SaveFile (string fileName)
{
fileName += ".wav";
// first, we grab the current apps isolated storage handle
var storage = IsolatedStorageFile.GetUserStoreForApplication ();
// if that file exists...
if (storage.FileExists (fileName))
{
// then delete it
storage.DeleteFile (fileName);
}
// now we set up an isolated storage stream to point to store our data
var stream = new IsolatedStorageFileStream (fileName, FileMode.Create, IsolatedStorageFile.GetUserStoreForApplication ());
var streamArray = Utilities.MemoryStream.ToArray ();
stream.Write (streamArray, 0, streamArray.Length);
// ok, done with isolated storage... so close it
stream.Close ();
Utilities.MemoryStream = null;
}
示例4: btnLeLog_Click
private void btnLeLog_Click(object sender, RoutedEventArgs e)
{
mut.WaitOne();//Espera até a thread poder trabalhar ( acessar nosso recurso .txt );
IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication();
if (!isoFile.DirectoryExists("/Logs/"))
{
mut.ReleaseMutex();// Liebro o meu mutex
MessageBox.Show("Nenhum log foi encontrado");
return;
}
IsolatedStorageFileStream isoLogFileStream = new IsolatedStorageFileStream(
"\\Logs\\MeuLog.txt",
System.IO.FileMode.Open,
isoFile);
StreamReader reader = new StreamReader(isoLogFileStream);
string log = reader.ReadToEnd();
//Liberar todos os recursos
isoLogFileStream.Close();
reader.Close();
// Liebro o meu mutex
mut.ReleaseMutex();
MessageBox.Show(log);
}
示例5: OnNavigatedFrom
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
// Load from storage
IsolatedStorageFileStream location = new IsolatedStorageFileStream("xmppcred.item", System.IO.FileMode.Create, storage);
DataContractSerializer ser = new DataContractSerializer(typeof(List<XMPPAccount>));
if (App.Options.SavePasswords == false)
{
foreach (XMPPAccount account in Accounts)
{
account.Password = "";
}
}
try
{
ser.WriteObject(location, Accounts);
}
catch (Exception)
{
}
location.Close();
}
base.OnNavigatedFrom(e);
}
示例6: IsolatedStorage
public void IsolatedStorage()
{
// Get a new isolated store for this user, domain, and assembly.
// Put the store into an IsolatedStorageFile object.
IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, null, null);
// This code creates a few different directories.
isoStore.CreateDirectory("TopLevelDirectory");
isoStore.CreateDirectory("TopLevelDirectory/SecondLevel");
// This code creates two new directories, one inside the other.
isoStore.CreateDirectory("AnotherTopLevelDirectory/InsideDirectory");
// This file is placed in the root.
IsolatedStorageFileStream isoStream1 = new IsolatedStorageFileStream("InTheRoot.txt", FileMode.Create, isoStore);
Console.WriteLine("Created a new file in the root.");
isoStream1.Close();
// This file is placed in the InsideDirectory.
IsolatedStorageFileStream isoStream2 = new IsolatedStorageFileStream("AnotherTopLevelDirectory/InsideDirectory/HereIAm.txt", FileMode.Create, isoStore);
isoStream2.Close();
Console.WriteLine("Created a new file in the InsideDirectory.");
}
示例7: downloadComplete
public void downloadComplete(Object sender, DownloadStringCompletedEventArgs e)
{
String result;
Boolean web;
try
{
result = e.Result;
web = true;
}
catch (WebException we)
{
result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\"><gesmes:subject>Reference rates</gesmes:subject><gesmes:Sender><gesmes:name>European Central Bank</gesmes:name></gesmes:Sender><Cube><Cube time='2011-04-19'><Cube currency='USD' rate='1.4302'/><Cube currency='JPY' rate='118.23'/><Cube currency='BGN' rate='1.9558'/><Cube currency='CZK' rate='24.125'/><Cube currency='DKK' rate='7.4576'/><Cube currency='GBP' rate='0.87800'/><Cube currency='HUF' rate='266.88'/><Cube currency='LTL' rate='3.4528'/><Cube currency='LVL' rate='0.7093'/><Cube currency='PLN' rate='3.9785'/><Cube currency='RON' rate='4.0885'/><Cube currency='SEK' rate='8.9210'/><Cube currency='CHF' rate='1.2842'/><Cube currency='NOK' rate='7.7635'/><Cube currency='HRK' rate='7.3580'/><Cube currency='RUB' rate='40.4869'/><Cube currency='TRY' rate='2.1936'/><Cube currency='AUD' rate='1.3622'/><Cube currency='BRL' rate='2.2647'/><Cube currency='CAD' rate='1.3694'/><Cube currency='CNY' rate='9.3399'/><Cube currency='HKD' rate='11.1240'/><Cube currency='IDR' rate='12422.61'/><Cube currency='ILS' rate='4.9137'/><Cube currency='INR' rate='63.6220'/><Cube currency='KRW' rate='1557.28'/><Cube currency='MXN' rate='16.7398'/><Cube currency='MYR' rate='4.3271'/><Cube currency='NZD' rate='1.8154'/><Cube currency='PHP' rate='61.973'/><Cube currency='SGD' rate='1.7835'/><Cube currency='THB' rate='42.992'/><Cube currency='ZAR' rate='9.7827'/></Cube></Cube></gesmes:Envelope>";
web = false;
}
IsolatedStorageFileStream file = new IsolatedStorageFileStream("coin.xml", FileMode.OpenOrCreate, IsolatedStorageFile.GetUserStoreForApplication());
if ((file.Length <= 0) || web)
{
using (StreamWriter stream = new StreamWriter(file))
{
stream.Write(result);
stream.Close();
}
}
file.Close();
updateUi();
}
示例8: ReadFromIsolatedStorage
public static void ReadFromIsolatedStorage()
{
IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication();
highscore = new List<Pair>();
string[] fileNames = isolatedStorageFile.GetFileNames("highscore2.txt");
if (fileNames.Length == 0)
{
Console.WriteLine("User has saved no data yet.");
}
else
{
IsolatedStorageFileStream isolatedStorageFileStream = new IsolatedStorageFileStream("highscore2.txt", FileMode.Open, isolatedStorageFile);
StreamReader streamReader = new StreamReader(isolatedStorageFileStream);
while (streamReader.Peek() >= 0)
{
string n = streamReader.ReadLine();
int x = Int32.Parse(streamReader.ReadLine());
Highscore.Add(new Pair(x, n));
}
streamReader.Close();
isolatedStorageFileStream.Close();
}
}
示例9: CopyFile
private static string CopyFile(string filename)
{
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
Stream input = null;
Stream output = null;
string absoulutePath = Windows.Storage.ApplicationData.Current.LocalFolder.Path + '\\' + filename;
if (!File.Exists(absoulutePath))
{
input = Application.GetResourceStream(new Uri(filename, UriKind.Relative)).Stream;
output = new IsolatedStorageFileStream(filename, FileMode.CreateNew, isoStore);
CopyFile(input, output);
input.Close();
input = null;
output.Flush();
output.Close();
output = null;
}
return absoulutePath;
}
示例10: clear
public void clear()
{
debugFile = new System.IO.IsolatedStorage.IsolatedStorageFileStream(debugFileName,
System.IO.FileMode.Create,
local);
debugFile.Close();
}
示例11: wc_OpenReadCompleted
void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
if (e.Error == null && !e.Cancelled)
{
string iconPath = "1.txt";
using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
{
var isfs = new IsolatedStorageFileStream(iconPath, FileMode.Create, isf);
int bytesRead;
byte[] bytes = new byte[e.Result.Length];
while ((bytesRead = e.Result.Read(bytes, 0, bytes.Length)) != 0)
{
isfs.Write(bytes, 0, bytesRead);
}
isfs.Flush();
isfs.Close();
}
this.Dispatcher.BeginInvoke(() =>
{
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
});
}
}
示例12: SlowkaClass
public SlowkaClass()
{
slowka = new List<Slowko>();
XDocument doc = null;
IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream storageStream = null;
if(storage.FileExists("slowka.xml"))
{
storageStream = new IsolatedStorageFileStream("slowka.xml", System.IO.FileMode.Open, FileAccess.Read, storage);
doc = XDocument.Load(storageStream);
storageStream.Close();
}
else
{
doc = XDocument.Load("slowka.xml");
storageStream = new IsolatedStorageFileStream("slowka.xml", System.IO.FileMode.CreateNew, FileAccess.Write, storage);
doc.Save(storageStream);
storageStream.Close();
}
//var vSlowka = from s in XElement.Load("slowka.xml").Element("slowko").Elements() select s;
var v = from s in doc.Descendants("slowko") select new Slowko(s);
slowka.AddRange(v);
}
示例13: Main
static void Main(string[] args)
{
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly();
IsolatedStorageFileStream isoFile = new IsolatedStorageFileStream("myfile.txt", FileMode.Create, isoStore);
Console.WriteLine(isoFile.GetType().GetField("m_FullPath", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(isoFile).ToString());
StreamWriter sw = new StreamWriter(isoFile);
sw.WriteLine("This text is written to an isolated storage file.");
sw.Close();
isoFile.Close();
isoFile = new IsolatedStorageFileStream("myfile.txt", FileMode.Open, isoStore);
StreamReader sr = new StreamReader(isoFile);
Console.WriteLine(sr.ReadToEnd());
sr.Close();
isoFile.Close();
}
示例14: Main
static void Main(string[] args)
{
string text = "";
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly();
IsolatedStorageFileStream isoFile = new IsolatedStorageFileStream("output.txt", FileMode.Create, isoStore);
StreamWriter sw = new StreamWriter(isoFile);
Console.WriteLine("Please enter text now. Enter 'quit' when finished...");
while ((text=Console.ReadLine()) != "quit")
{
sw.WriteLine(text);
}
sw.Flush();
sw.Close();
isoFile.Close();
Console.Clear();
Console.WriteLine("Text entered in to isloated storage...");
isoFile = new IsolatedStorageFileStream("output.txt", FileMode.Open, isoStore);
StreamReader sr = new StreamReader(isoFile);
Console.WriteLine(sr.ReadToEnd());
isoFile.Close();
sr.Close();
Console.ReadLine();
}
示例15: IsolatedStorage_Read_and_Write_Sample
public static void IsolatedStorage_Read_and_Write_Sample()
{
string fileName = @"SelfWindow.xml";
IsolatedStorageFile storFile = IsolatedStorageFile.GetUserStoreForDomain();
IsolatedStorageFileStream storStream = new IsolatedStorageFileStream(fileName, FileMode.Create, FileAccess.Write);
System.Xml.XmlWriter writer = new System.Xml.XmlTextWriter(storStream, Encoding.UTF8);
writer.WriteStartDocument();
writer.WriteStartElement("Settings");
writer.WriteStartElement("UserID");
writer.WriteValue(42);
writer.WriteEndElement();
writer.WriteStartElement("UserName");
writer.WriteValue("kingwl");
writer.WriteEndElement();
writer.WriteEndElement();
writer.Flush();
writer.Close();
storStream.Close();
string[] userFiles = storFile.GetFileNames();
foreach(var userFile in userFiles)
{
if(userFile == fileName)
{
var storFileStreamnew = new IsolatedStorageFileStream(fileName,FileMode.Open,FileAccess.Read);
StreamReader storReader = new StreamReader(storFileStreamnew);
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(storReader);
int UserID = 0;
string UserName = null;
while(reader.Read())
{
switch(reader.Name)
{
case "UserID":
UserID = int.Parse(reader.ReadString());
break;
case "UserName":
UserName = reader.ReadString();
break;
default:
break;
}
}
Console.WriteLine("{0} {1}", UserID, UserName);
storFileStreamnew.Close();
}
}
storFile.Close();
}