Can't use NSTexView.FromRtfdFile

Denys de Marcoussis 1 Reputation point

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("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());
            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());
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,146 questions
0 comments No comments
{count} votes