question

DenysdeMarcoussis-6287 avatar image
0 Votes"
DenysdeMarcoussis-6287 asked

Can't use NSTexView.FromRtfdFile

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());
         }
     }
dotnet-macos
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers