Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Xamarin Forms - Saving Files (Environment.SpecialFolder.Personal does not work)

$
0
0

Hi , i'm having a small issue with Xamarin.Forms

This works -

    Java.IO.File path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim);

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(System.IO.Path.Combine(path.AbsolutePath, "dsdsd.txt"), false))
            {
                sw.WriteLine("yoyoyoyoy");
                sw.Close();
            }

However , using the XF Folder options as in "Working With Files" Guide ..The file is not created

    var fPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
    string filePath = Path.Combine(fpath, "dsdsd.txt");

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(filepath, false))
            {
                sw.WriteLine("yoyoyoyoy");
                sw.Close();
            }

Any idea what is causing this issue ?

I would prefer to use my App folder instead of a public one .

I did a test on the paths :

With Xamarin Environment :

/data/data/TestApp.Droid/files/dsdsd.txt  (Does not work)

With Android Path :

/storage/emulated/0/DCIM/dsdsd.txt  (works)

My Actual app Folder path (When i browse using pc) :

\Phone\Android\data\TestApp.Droid\files

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>