mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-04-17 18:16:28 +03:00
Fix/AccessException
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
x:Name="ThisWindow">
|
||||
|
||||
<Grid ColumnDefinitions="1.5*, 2*">
|
||||
<!-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) -->
|
||||
<!-- Левая синяя панель (без логотипа и заголовка) -->
|
||||
<Border Background="#2328C4" Grid.Column="0">
|
||||
<StackPanel VerticalAlignment="Center" Margin="20">
|
||||
<TextBlock Text="Choose where to save your password database"
|
||||
@@ -24,7 +24,7 @@
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -->
|
||||
<!-- Правая белая панель с формой -->
|
||||
<StackPanel Grid.Column="1" Margin="30" VerticalAlignment="Center" Spacing="20">
|
||||
<TextBlock Text="File location"
|
||||
FontSize="22"
|
||||
@@ -33,10 +33,9 @@
|
||||
|
||||
<Grid ColumnDefinitions="*, Auto" RowDefinitions="Auto" ColumnSpacing="10">
|
||||
<TextBox x:Name="FilePathTextBox"
|
||||
Grid.Column="0"
|
||||
Watermark="Select file path..."
|
||||
Text="{Binding #ThisWindow.FilePath, Mode=TwoWay}"
|
||||
Padding="10,8"/>
|
||||
Grid.Column="0"
|
||||
Watermark="Select file path..."
|
||||
Padding="10,8"/>
|
||||
<Button x:Name="BrowseButton"
|
||||
Grid.Column="1"
|
||||
Content="Browse..."
|
||||
@@ -45,13 +44,13 @@
|
||||
Click="BrowseButton_Click"/>
|
||||
</Grid>
|
||||
|
||||
<!-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> -->
|
||||
<!-- Предупреждение о существующем файле -->
|
||||
<TextBlock x:Name="PathWarning"
|
||||
FontSize="12"
|
||||
Foreground="Orange"
|
||||
Text=" " />
|
||||
|
||||
<!-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -->
|
||||
<!-- Кнопки действий -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="10" Margin="0,20,0,0">
|
||||
<Button Content="Cancel"
|
||||
Classes="secondaryButton"
|
||||
|
||||
@@ -21,18 +21,25 @@ namespace KeyKeeper.Views
|
||||
FilePathTextBox.TextChanged += OnTextChanged;
|
||||
}
|
||||
|
||||
private void OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
private async void OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
string path = FilePathTextBox.Text ?? "";
|
||||
CreateButton.IsEnabled = !string.IsNullOrWhiteSpace(path);
|
||||
PathWarning.Text = "";
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(path) && File.Exists(path))
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
PathWarning.Text = "File already exists. It will be overwritten.";
|
||||
var storageFile = await StorageProvider.TryGetFileFromPathAsync(path);
|
||||
if (storageFile != null)
|
||||
{
|
||||
PathWarning.Text = "File already exists. It will be overwritten.";
|
||||
}
|
||||
}
|
||||
else
|
||||
catch
|
||||
{
|
||||
PathWarning.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user