如何以用户可以找到的 xamarin 形式将文件写入内部存储 [英] How to write a file to a Internal Storage in xamarin forms which can be found by the user

查看:43
本文介绍了如何以用户可以找到的 xamarin 形式将文件写入内部存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力将文件写入内部存储.我想通过为我的应用程序创建一个单独的文件夹来将文件保存到用户可以看到它并读取文件(例如 Mydocuments 或内部存储)的位置,就像 whatsapp 一样.我也想在 iOS 中使用相同的场景.

I've been struggling to write a file to the internal storage. I want to save the file to such a location where the user can see it and read the file such as Mydocuments or in the Internal storage by creating a seperate folder for my app like whatsapp does. I also want the same scenario in iOS.

我该怎么做?我已经尝试了 Xamarin.Essentials 中的 FileSystem Helpers,也使用了 Environment.SpecialFolder 但似乎没有任何效果.我只是想保存一个简单的文本文件.

How do i do that? I have tried the FileSystem Helpers in Xamarin.Essentials and have also used the Environment.SpecialFolder but nothing seems to work. I am just trying to save a simple text file.

我尝试过的链接..

https://docs.microsoft.com/en-我们/xamarin/android/platform/files/

https://docs.microsoft.com/en-us/xamarin/essentials/file-system-helpers?context=xamarin%2Fandroid&tabs=android

注意:我对外部存储不感兴趣.

NOTE: I am not interested in the External storage.

推荐答案

适用于正在寻找答案的人.请访问此链接 =>https://stackoverflow.com/a/63777656/9048996

For people who are searching for the answer. Please visit this link => https://stackoverflow.com/a/63777656/9048996

这里有一个解决方案,它有助于在我们的内部存储或外部存储(如果可用)中创建一个单独的目录.然后,您可以在该专用目录中创建您自己的文件,这些文件是公开的并且对用户可见,以便他们可以在需要时共享它们.提供的解决方案仅适用于 android.

Here there is solution which helps to create a seperate directory in our internal storage or external if available. Then you can create your own files in that dedicated directory and the files are public and is visible to the user so that they can share them if required. The provided solution is only for android.

这篇关于如何以用户可以找到的 xamarin 形式将文件写入内部存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆