Since the answer here doesn't solve your problem. I'm posting an alternate walkaround that may help for testing stuff.
If you can use a WPF project instead of a console application you'll be able to:
- View arabic text on the screen.
- Scroll over the entire output of your execution
- Easily copy the output
- Keep using C# as a coding language
Create a WPF project and add a multiligne textBox to your WPF design that has the following properties:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox HorizontalAlignment="Stretch" AcceptsReturn="True"
TextAlignment="Right"
VerticalScrollBarVisibility="Auto"
Name="textBox1" VerticalAlignment="Stretch"/>
</Grid>
TextAlignment to right as in arabic, VerticalScrollBarVisibility to view all the output and AcceptsReturn to have a multiline textBox. The HorizontalAlignment and VerticalAlignment set to stretch to fill all the displayed window.
You could add a method in the code section to ease the adding of String in this textBox, the method could be like this:
private void writeToTextBox(string textToWrite)
{
textBox1.Text += textToWrite + "\n";
}
The global code behing would be:
namespace WpfApplication1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
createSourateFromXML();
}
private void createSourateFromXML()
{
string xmlquranfile = @"C:\Users\hp\Downloads\quran-simple.xml";
XmlDocument xml_quran = new XmlDocument();
xml_quran.Load(xmlquranfile);
foreach (XmlNode soura in xml_quran.DocumentElement.ChildNodes)
{
writeToTextBox(soura.Attributes["name"].Value);
}
}
private void writeToTextBox(string textToWrite)
{
textBox1.Text += textToWrite + "\n";
}
}
The foreach loops over names in my xml file and adds them to the WPF textBox.
This is a screenshot of the execution result https://i.sstatic.net/MIdOY.png
You can tune the display by changing the textBox properties, things like font, style, size are all customizable.