本文整理汇总了C#中IFolder.CreateFileAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IFolder.CreateFileAsync方法的具体用法?C# IFolder.CreateFileAsync怎么用?C# IFolder.CreateFileAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFolder
的用法示例。
在下文中一共展示了IFolder.CreateFileAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DownloadFileAsync
public static async Task<bool> DownloadFileAsync(IFolder folder, string url, string fileName)
{
using (var client = new HttpClient())
using (var response = await client.GetAsync(url))
{
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
Stream temp = await response.Content.ReadAsStreamAsync();
IFile file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
using (var fs = await file.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))
{
await temp.CopyToAsync(fs);
fs.Close();
return true;
}
}
else
{
Debug.WriteLine("NOT FOUND " + url);
return false;
}
}
}
示例2: createFileSystem
public async void createFileSystem(IFolder fileSystem)
{
var loc = await App.dbWrapper.GetLocation();
var cloudList = await App.dbWrapper.GetAvailableClouds(loc[0], loc[1]);
string cloudNamesString = "";
for(int i =0; i<cloudList.Count; i++)
{
cloudNamesString +=(cloudList[i].Title) + ",";
System.Diagnostics.Debug.WriteLine(cloudList[i].Title);
}
IFile file = await fileSystem.CreateFileAsync("PhoneData.txt", CreationCollisionOption.ReplaceExisting);
string baseString = "a\nUVA,"+cloudNamesString+"\n"; ///GOTO: settings page if this is modified
await file.WriteAllTextAsync(baseString);
var navPage = new NavigationPage(new CarouselTutorialPage());
MainPage = navPage;
}
示例3: createCleanFileSystem
public async void createCleanFileSystem(IFolder fileSystem)
{
IFile file = await fileSystem.CreateFileAsync("PhoneData.txt", CreationCollisionOption.ReplaceExisting);
string baseString = "a\nUVA,\n"; ///GOTO: settings page if this is modified
await file.WriteAllTextAsync(baseString);
var navPage = new NavigationPage(new CarouselTutorialPage());
MainPage = navPage;
}
示例4: CreateFileAsync
public static async Task<IFile> CreateFileAsync(string path, IFolder folder,
CreationCollisionOption option = CreationCollisionOption.OpenIfExists)
{
if (path.StartsWith("/") || path.StartsWith("\\"))
path = path.Substring(1);
var parts = path.Split('/');
var fileName = parts.Last();
if (parts.Length > 1)
{
folder =
await
EnsureFolderExistsAsync(path.Substring(0, path.Length - fileName.Length), folder)
.DontMarshall();
}
return await folder.CreateFileAsync(fileName, option).DontMarshall();
}