How to upload text from a file into monaco text editor WPF C# .Net

Aidan Kinzie 66 Reputation points
2022-08-08T14:52:57.177+00:00

229137-image.png

Developer technologies | Windows Presentation Foundation
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 61,101 Reputation points
    2022-08-08T15:03:15.32+00:00

    Just guessing here but setValue requires a string. You are passing the raw string value. Imagine text contains Hello World. You're script is actually:

       editor.setValue(Hello World);  
    

    You need to enclose the string in quotes.

       await Editor.ExecuteScriptAsync($"editor.setValue('{text}');");  
    

  2. Aidan Kinzie 66 Reputation points
    2022-08-08T17:28:53.817+00:00

    229237-image.png

    Its not wanting to upload, but the file is a txt file containing Print("Hello") on line 1 and Print("World") on line 2. It works when I delete line 2 but it fails when line 2 exists. The language is lua.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.