Ambiguous reference between System.Enviroment.GetFolderPath and Android.OS.Enviroment.GetFolderPath

Hi,

I am trying to export and write to some files using this code:
var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments); var filename = Path.Combine (documents, "Write.txt"); File.WriteAllText(filename, "Write this text into a file!");

But I am getting this error: Ambiguous reference between System.Enviroment.GetFolderPath and Android.OS.Enviroment.GetFolderPath

I build my project for android,and also I am using Systtem.IO;

Thanks

Answers

  • xProjectsxProjects ✭✭ USMember ✭✭

    XAM160 - error in Ex 1. leads to the same "ambiguous reference" issue
    Error CS0104 'Environment' is an ambiguous reference between 'Android.OS.Environment' and 'System.Environment' People.Droid C:\Training\Xamarin\XUniversity\Xam160\People\People\People.Droid\FileAccessHelper.cs 20 Active

    This Solution may help:
    instead of this code from the exercise:
    string path = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
    Explicitly prepend the "System." to the Environment.SpecialFolder.Personal) statement:
    string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

    I hope this helps.

  • ValyallahAyobiValyallahAyobi USMember

    @xProjects said:
    XAM160 - error in Ex 1. leads to the same "ambiguous reference" issue
    Error CS0104 'Environment' is an ambiguous reference between 'Android.OS.Environment' and 'System.Environment' People.Droid C:\Training\Xamarin\XUniversity\Xam160\People\People\People.Droid\FileAccessHelper.cs 20 Active

    This Solution may help:
    instead of this code from the exercise:
    string path = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
    Explicitly prepend the "System." to the Environment.SpecialFolder.Personal) statement:
    string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

    I hope this helps.

    it worked ... thanks

Sign In or Register to comment.