Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,334 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I begin developing on VisualStudio for MacOs and try to store and reload the rich text content of a NSTextView.
Writing to a file is ok.
Reading with FromRtfdFile don't work.
If I try with ReadDataToEndOfFile it's Ok.
FromRtfdFile is more conveniant for me.
Any idea? Thank you in advance
Don't work :
partial void action_chargeData(NSObject sender)
{
NSTextView textView = outlet_data;
NSUrl url = path("toto.txt"); //path returns the url (controled)
Console.WriteLine("Read: " + url.ToString());
if (textView.FromRtfdFile(url.ToString())) //???
Console.WriteLine("Ok");
else
Console.WriteLine("Read error...");
}
Works fine:
private void lisFichier()
{
NSUrl url = path("toto.txt");
NSError erreur;
NSFileHandle fileH = NSFileHandle.OpenReadUrl(url, out erreur);
if (erreur!=null)
Console.WriteLine("erreur " + erreur.ToString());
else
{
NSData datas = fileH.ReadDataToEndOfFile();
NSTextView textView = outlet_data;
NSRange rang = new NSRange(0, 0);
textView.ReplaceWithRtfd(rang, datas); //for test
Console.WriteLine("lu: " + datas.ToString());
}
}