c
/// <summary> /// 复制资源文件(/Resources/Raw/) /// </summary> /// <param name="resourceFileName">资源文件名</param> public async static Task CopyFileFromResource(string resourceFileName) { //FileSystem.Current.AppDataDirectory 程序文件目录 string filePath = System.IO.Path.Combine(FileSystem.Current.AppDataDirectory, resourceFileName); if (File.Exists(filePath)) { File.Delete(filePath); } //资源文件是否存在 bool resExists = await FileSystem.Current.AppPackageFileExistsAsync(resourceFileName); if (resExists) { //资源文件流 using System.IO.Stream fileStream = await FileSystem.Current.OpenAppPackageFileAsync(resourceFileName); // 缓冲区为10k byte[] buffer = new Byte[10000]; // 文件长度 int length; //目标文件流 using System.IO.FileStream fs = new System.IO.FileStream(filePath, FileMode.OpenOrCreate); //循环写入 do { length = fileStream.Read(buffer, 0, 10000); fs.Write(buffer, 0, length); buffer = new Byte[10000]; } while (length > 0); //刷新缓存,结束。 fs.Flush(); } }
分类:
.Net MAUI Blazor
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
2018-01-26 css背景图充满屏幕