本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFile.CreateFile方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFile.CreateFile方法的具体用法?C# IsolatedStorageFile.CreateFile怎么用?C# IsolatedStorageFile.CreateFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.IsolatedStorage.IsolatedStorageFile
的用法示例。
在下文中一共展示了IsolatedStorageFile.CreateFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Accelerometro
public Accelerometro()
{
InitializeComponent();
accelerometer = new Accelerometer();
accelerometer.TimeBetweenUpdates = TimeSpan.FromMilliseconds(100);
accelerometer.Start();
myFile = IsolatedStorageFile.GetUserStoreForApplication();
if (!myFile.FileExists("Impo.txt"))
{
IsolatedStorageFileStream dataFile = myFile.CreateFile("Impo.txt");
dataFile.Close();
}
Wb = new WebBrowser();
Connesso = false;
Carica();
System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();
dt.Interval = new TimeSpan(0, 0, 0, 0, 250); // 500 Milliseconds
dt.Tick += new EventHandler(dt_Tick);
dt.Start();
}
示例2: IsolatedStorageFileWrapper_Tests
public IsolatedStorageFileWrapper_Tests()
{
storage = IsolatedStorageFile.GetUserStoreForAssembly();
directory = new IsolatedStorageDirectory(storage);
using (var stream = storage.CreateFile("exists.js"))
{
"content".AsStream().CopyTo(stream);
stream.Flush();
}
}
示例3: WriteTextFile
protected static void WriteTextFile(IsolatedStorageFile isf, string path, string text)
{
using (var fs = isf.CreateFile(path))
{
using (var sw = new StreamWriter(fs))
{
sw.Write(text);
}
}
}
示例4: PrepareStartRecordToTempFile
public string PrepareStartRecordToTempFile()
{
RecordLevel = 0;
useTempFile = true;
isf = IsolatedStorageFile.GetUserStoreForApplication();
tempFileKey = Guid.NewGuid().ToString() + ".tmp";
tempFileStream = isf.CreateFile(tempFileKey);
_sampleDuration = TimeSpan.FromSeconds(0);
FrameworkDispatcher.Update();
//_dispatcherTimer.Start();
return tempFileKey;
}
示例5: MainPage
public MainPage()
{
InitializeComponent();
myFile = IsolatedStorageFile.GetUserStoreForApplication();
if (!myFile.FileExists("Impo.txt"))
{
IsolatedStorageFileStream dataFile = myFile.CreateFile("Impo.txt");
dataFile.Close();
}
}
示例6: SaveDetails
private void SaveDetails(IsolatedStorageFile store)
{
using (var fs = store.CreateFile(InfoPath))
SaveDetails(fs);
}
示例7: Save
/// <summary>
/// Saves user password.
/// </summary>
/// <param name="store">The store.</param>
/// <param name="xml">The XML.</param>
private async void Save(IsolatedStorageFile store,
DbPersistentData xml)
{
if (!store.DirectoryExists(Folder))
store.CreateDirectory(Folder);
using (var fs = store.CreateFile(ProtectionPath))
{
var protect = xml.Protection;
fs.Write(protect, 0, protect.Length);
}
using (var fs = store.CreateFile(ParsedXmlPath))
using (var buffer = new MemoryStream(xml.Xml))
BufferEx.CopyStream(buffer, fs);
using (var fs = store.CreateFile(MasterPasswordPath))
{
var data = xml.MasterKey;
await fs.WriteAsync(data, 0, data.Length);
}
}
示例8: Store
public override void Store( string url, BitmapSource bitmap )
{
Deployment.Current.Dispatcher.BeginInvoke( () => {
string fileName = GetFilePath( GetFileName( url ) );
using ( _storage = IsolatedStorageFile.GetUserStoreForApplication() ) {
if ( _storage.FileExists( fileName ) ) {
_storage.DeleteFile( fileName );
}
using ( IsolatedStorageFileStream fileStream = _storage.CreateFile( fileName ) ) {
WriteableBitmap writeableBitmap = new WriteableBitmap( bitmap );
writeableBitmap.SaveJpeg( fileStream, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight, 0, IMAGE_QUALITY );
}
}
} );
}
示例9: SaveMultimedia
private async Task SaveMultimedia(IsolatedStorageFile isoStore, string snapshotDir, IProgress<Tuple<BackupStage, int>> Progress) {
Progress.Report(Tuple.Create(BackupStage.ExternalData, 0));
var snapshotMultimediaDir = Path.Combine(snapshotDir, MultimediaStorageService.MEDIA_FOLDER);
var snapshotDBPath = Path.Combine(snapshotDir, DiversityDataContext.DB_FILENAME);
using (var db = new DiversityDataContext(snapshotDBPath)) {
var totalCount = db.MultimediaObjects.Count();
if (totalCount > 0) {
var reporter = new PercentageReporter<Tuple<BackupStage, int>>(
Progress,
p => Tuple.Create(BackupStage.ExternalData, p),
totalCount);
foreach (var mm in db.MultimediaObjects) {
var descriptor = StorageDescriptor.FromURI(mm.Uri);
if (descriptor.Type == StorageType.CameraRoll) {
using (var content = ImageStore.GetMultimedia(mm.Uri)) {
var mmFilePath = Path.Combine(snapshotMultimediaDir, descriptor.FileName);
using (var targetFile = isoStore.CreateFile(mmFilePath)) {
await content.CopyToAsync(targetFile);
descriptor.Type = StorageType.IsolatedStorage;
mm.Uri = descriptor.ToString();
}
}
}
reporter.Completed++;
}
db.SubmitChanges();
}
}
}
示例10: SaveCompletedTimeStamp
private static void SaveCompletedTimeStamp(string snapshotDir, IsolatedStorageFile isoStore) {
var completedMarkerPath = Path.Combine(snapshotDir, COMPLETED_MARKER);
using (var completedFile = isoStore.CreateFile(completedMarkerPath))
using (var writer = new StreamWriter(completedFile)) {
var universalNow = DateTime.Now.ToUniversalTime();
var invariantNowString = universalNow.ToString(CultureInfo.InvariantCulture);
writer.WriteLine(invariantNowString);
writer.Flush();
}
}
示例11: WriteFileToFile
private static void WriteFileToFile(File file, IsolatedStorageFile istorage, string newFilePath)
{
using (var newFile = istorage.CreateFile(newFilePath))
{
using (var newWriteableFile = new StreamWriter(newFile, Encoding.Unicode))
{
newWriteableFile.Write(file.Content);
newWriteableFile.Flush();
}
}
}
示例12: ImportOrMakeSoundsCache
private void ImportOrMakeSoundsCache(IsolatedStorageFile isf)
{
_soundFiles = new Dictionary<int, string>();
foreach (var sound in Cartridge.Resources.Where(m => m.Type == MediaType.MP3 || m.Type == MediaType.WAV))
{
// Copies the sound file to the cache if it doesn't exist already.
string cacheFilename = GetCachePathCore(sound);
if (!isf.FileExists(cacheFilename))
{
using (IsolatedStorageFileStream fs = isf.CreateFile(cacheFilename))
{
fs.Write(sound.Data, 0, sound.Data.Length);
}
}
// Adds the sound filename to the dictionary.
_soundFiles.Add(sound.MediaId, cacheFilename);
}
RaisePropertyChanged("Sounds");
}
示例13: ExtractFile
private static void ExtractFile(IsolatedStorageFile store, string baseFileName)
{
if (!store.FileExists(baseFileName))
{
using (Stream sourceStream = Application.GetResourceStream(new Uri("Data/" + baseFileName, UriKind.Relative)).Stream)
{
using (IsolatedStorageFileStream targetStream = store.CreateFile(baseFileName))
{
byte[] buffer = new byte[1024];
int length;
while ((length = sourceStream.Read(buffer, 0, 1024)) > 0)
targetStream.Write(buffer, 0, length);
targetStream.Close();
}
sourceStream.Close();
}
}
}
示例14: WriteToIsolatedStorage
private static void WriteToIsolatedStorage(IsolatedStorageFile storage, System.IO.Stream inputStream, string fileName)
{
IsolatedStorageFileStream outputStream = null;
try
{
if (!storage.DirectoryExists(imageStorageFolder))
{
storage.CreateDirectory(imageStorageFolder);
}
if (storage.FileExists(fileName))
{
storage.DeleteFile(fileName);
}
outputStream = storage.CreateFile(fileName);
byte[] buffer = new byte[32768];
int read;
while ((read = inputStream.Read(buffer, 0, buffer.Length)) > 0)
{
outputStream.Write(buffer, 0, read);
}
outputStream.Dispose();
}
catch
{
//We cannot do anything here.
outputStream?.Dispose();
}
}
示例15: SaveDetails
private void SaveDetails(IsolatedStorageFile store)
{
using (var fs = store.CreateFile(InfoPath))
{
var writer = new StreamWriter(fs);
var serializer = new JsonSerializer();
serializer.Serialize(writer, Details);
writer.Flush();
}
}