Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

NullReferenceException - File.WriteAllText Xamarin/Android ?

NullReferenceException - File.WriteAllText Xamarin/Android ?

Try the following code

 //file path
var filePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "RecentHosts.txt");
if (!File.Exists(filePath))
{
    File.Create(filePath);
}

string text = JsonConvert.SerializeObject(new JsonHosts() { hosts = RecentHosts.Values.ToList() });
//write in file
File.WriteAllText(filePath, text);

7 0

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online