Не удалось найти часть пути wpf
Пытаюсь получить информацию из файла и вывести ее на экран, однако вылезает ошибка не удаётся "Не удалось найти часть пути". Всё перепроверил, всё правильно. Подскажите пожалуйста, из-за чего может появляться эта ошибка? Только изучаю эту тему поэтому очень прошу помочь, буду очень благодарен. Вот мой код:
xaml:
<Window x:Class="MshpHW1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MshpHW1"
mc:Ignorable="d"
Title="MainWindow" Height="550" Width="725">
<Grid>
<Label Margin="30,70,282,319" FontSize="25">
<TextBlock TextAlignment="Left">Для работы автомата <LineBreak/>требуется загрузить меню</TextBlock>
</Label>
<Button x:Name="Upload" Content="Загрузить" Width="120" Height="80" Margin="280 -280 -150 0" Click="Upload_Click"/>
<Button x:Name="Menu1" Width="150" Height="40" Margin="-400 90 0 0"/>
<Button x:Name="Menu2" Width="150" Height="40" Margin="0 90 -200 0"/>
<Button x:Name="Do" Content="D o" Width="150" Height="180" Margin="-400 350 0 0"/>
<Image x:Name="Coffee" Width="150" Height="180" Margin="384,350,183,-11"/>
</Grid>
</Window>
c#:
public partial class MainWindow
{
private string[] Arr { get; set; }
public MainWindow()
{
InitializeComponent();
}
private void Upload_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Text Files(*.txt)| *.txt";
if (openFileDialog.ShowDialog() == true)
{
Uri uri = new Uri(openFileDialog.FileName, UriKind.Absolute);
Arr = File.ReadAllLines(uri.AbsolutePath);
foreach (string s in Arr)
{
Menu1.Content += s + "\n";
}
}
}
}