Skip to content

Commit b0e7693

Browse files
committed
Use IsValidForFilename method
1 parent 9789452 commit b0e7693

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Files.App/Filesystem/FilesystemOperations/Helpers/FilesystemHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ public async Task<ReturnResult> RecycleItemsFromClipboard(DataPackageView packag
648648

649649
#endregion IFilesystemHelpers
650650

651-
private static bool IsValidForFilename(string name)
651+
public static bool IsValidForFilename(string name)
652652
=> !string.IsNullOrWhiteSpace(name) && !ContainsRestrictedCharacters(name) && !ContainsRestrictedFileName(name);
653653

654654
private static async Task<(List<FileNameConflictResolveOptionType> collisions, bool cancelOperation, IEnumerable<IFileSystemDialogConflictItemViewModel>)> GetCollision(FilesystemOperationType operationType, IEnumerable<IStorageItemWithPath> source, IEnumerable<string> destination, bool forceDialog)

src/Files.App/Helpers/DynamicDialogFactory.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ public static DynamicDialog GetFor_RenameDialog()
6666

6767
TextBlock tipText = new()
6868
{
69-
Text = "RenameDialogSymbolsTip/Text".GetLocalizedResource(),
69+
Text = "InvalidFilename/Text".GetLocalizedResource(),
7070
Margin = new Microsoft.UI.Xaml.Thickness(0, 0, 4, 0),
7171
TextWrapping = Microsoft.UI.Xaml.TextWrapping.Wrap,
7272
Opacity = 0.0d
7373
};
7474

7575
inputText.TextChanged += (textBox, args) =>
7676
{
77-
tipText.Opacity = FilesystemHelpers.ContainsRestrictedCharacters(inputText.Text) ? 1.0d : 0.0d;
78-
dialog!.ViewModel.DynamicButtonsEnabled = string.IsNullOrWhiteSpace(inputText.Text) || FilesystemHelpers.ContainsRestrictedCharacters(inputText.Text)
79-
? DynamicDialogButtons.Cancel
80-
: DynamicDialogButtons.Primary | DynamicDialogButtons.Cancel;
77+
tipText.Opacity = FilesystemHelpers.IsValidForFilename(inputText.Text) ? 0.0d : 1.0d;
78+
dialog!.ViewModel.DynamicButtonsEnabled = FilesystemHelpers.IsValidForFilename(inputText.Text)
79+
? DynamicDialogButtons.Primary | DynamicDialogButtons.Cancel
80+
: DynamicDialogButtons.Cancel;
8181
};
8282

8383
inputText.Loaded += (s, e) =>

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@
513513
<data name="FileNameTeachingTip.CloseButtonContent" xml:space="preserve">
514514
<value>OK</value>
515515
</data>
516-
<data name="RenameDialogSymbolsTip.Text" xml:space="preserve">
517-
<value>The item name must not contain the following characters: \ / : * ? " &lt; &gt; |</value>
516+
<data name="InvalidFilename.Text" xml:space="preserve">
517+
<value>The item name specified is invalid</value>
518518
</data>
519519
<data name="ItemSelected.Text" xml:space="preserve">
520520
<value>item selected</value>

0 commit comments

Comments
 (0)