ios - 如何使用 xamarin.forms 创建文件夹以在 iOS 中存储下载的文件
问题描述
我正在尝试下载 pdf 文件并尝试使用 xamarin.forms 从我的应用程序中查看它。我能够在 android 设备中创建路径,但无法在 iPad 上创建路径。我需要创建自定义文件夹并需要下载该目录中的文件。如何实现。
string decoded = System.Text.Encoding.ASCII.GetString(fileBytes);
byte[] encodedDataAsBytes = DecodeUrlBase64(DataString);
string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
string finalPath=Path.Combine(documentsPath, Path.GetFileName(fileFullPath));
Directory.CreateDirectory(finalPath);
File.WriteAllBytes(finalPath, encodedDataAsBytes);
解决方案
删除后一切正常CreateDirectory
,以下是对我的代码所做的更改,这些更改按我的预期工作
byte[] encodedDataAsBytes = DecodeUrlBase64(DataString);
string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
string finalPath = Path.Combine(documentsPath, Path.GetFileName(fileFullPath));
File.WriteAllBytes(finalPath, encodedDataAsBytes);
推荐阅读
- javascript - 更改 classList.toggle 上元素内容的 CSS 方式
- ffmpeg - ffmpeg 无法解析 DASH-IF 清单
- python - python不能播放mp3文件,第一天学习代码
- java - 从 Seekbar Java 更新 int 值
- python - 为什么在我尝试重新加载 Django 网页后,我在 urls.py 中应用的更改没有反映出来?
- python - 使用循环条件将变量添加到字典中
- api - 如何向 VK API 发送 POST 请求
- sanity - 错误:在插件“@sanity/base”中找不到“sanity.json”文件
- flutter - 如何从新的持续时间重新启动 AnimationControler
- shell - 复制神器CURL中的最新神器