@@ -784,50 +784,65 @@ public async Task<bool> RenameFileItem(ListedItem item, string oldName, string n
784784 return false ;
785785 }
786786 }
787- catch
787+ catch ( Exception ex )
788788 {
789- var ItemAlreadyExistsDialog = new ContentDialog ( )
789+ if ( ex is ArgumentException )
790790 {
791- Title = ResourceController . GetTranslation ( "ItemAlreadyExistsDialogTitle" ) ,
792- Content = ResourceController . GetTranslation ( "ItemAlreadyExistsDialogContent" ) ,
793- PrimaryButtonText = ResourceController . GetTranslation ( "ItemAlreadyExistsDialogPrimaryButtonText" ) ,
794- SecondaryButtonText = ResourceController . GetTranslation ( "ItemAlreadyExistsDialogSecondaryButtonText" )
795- } ;
796-
797- ContentDialogResult result = await ItemAlreadyExistsDialog . ShowAsync ( ) ;
798-
799- if ( result == ContentDialogResult . Primary )
791+ await DialogDisplayHelper . ShowDialog ( ResourceController . GetTranslation ( "RenameError.NameInvalid.Title" ) , ResourceController . GetTranslation ( "RenameError.NameInvalid.Text" ) ) ;
792+ }
793+ else if ( ex is PathTooLongException )
794+ {
795+ await DialogDisplayHelper . ShowDialog ( ResourceController . GetTranslation ( "RenameError.TooLong.Title" ) , ResourceController . GetTranslation ( "RenameError.TooLong.Text" ) ) ;
796+ }
797+ else if ( ex is FileNotFoundException )
800798 {
801- if ( item . PrimaryItemAttribute == StorageItemTypes . Folder )
799+ await DialogDisplayHelper . ShowDialog ( ResourceController . GetTranslation ( "RenameError.ItemDeleted.Title" ) , ResourceController . GetTranslation ( "RenameError.ItemDeleted.Text" ) ) ;
800+ }
801+ else
802+ {
803+ var ItemAlreadyExistsDialog = new ContentDialog ( )
802804 {
803- var folder = await ItemViewModel . GetFolderFromPathAsync ( item . ItemPath ) ;
805+ Title = ResourceController . GetTranslation ( "ItemAlreadyExistsDialogTitle" ) ,
806+ Content = ResourceController . GetTranslation ( "ItemAlreadyExistsDialogContent" ) ,
807+ PrimaryButtonText = ResourceController . GetTranslation ( "ItemAlreadyExistsDialogPrimaryButtonText" ) ,
808+ SecondaryButtonText = ResourceController . GetTranslation ( "ItemAlreadyExistsDialogSecondaryButtonText" )
809+ } ;
804810
805- await folder . RenameAsync ( newName , NameCollisionOption . GenerateUniqueName ) ;
811+ ContentDialogResult result = await ItemAlreadyExistsDialog . ShowAsync ( ) ;
806812
807- App . JumpList . RemoveFolder ( folder . Path ) ;
808- }
809- else
813+ if ( result == ContentDialogResult . Primary )
810814 {
811- var file = await ItemViewModel . GetFileFromPathAsync ( item . ItemPath ) ;
815+ if ( item . PrimaryItemAttribute == StorageItemTypes . Folder )
816+ {
817+ var folder = await ItemViewModel . GetFolderFromPathAsync ( item . ItemPath ) ;
812818
813- await file . RenameAsync ( newName , NameCollisionOption . GenerateUniqueName ) ;
814- }
815- }
816- else if ( result == ContentDialogResult . Secondary )
817- {
818- if ( item . PrimaryItemAttribute == StorageItemTypes . Folder )
819- {
820- var folder = await ItemViewModel . GetFolderFromPathAsync ( item . ItemPath ) ;
819+ await folder . RenameAsync ( newName , NameCollisionOption . GenerateUniqueName ) ;
821820
822- await folder . RenameAsync ( newName , NameCollisionOption . ReplaceExisting ) ;
821+ App . JumpList . RemoveFolder ( folder . Path ) ;
822+ }
823+ else
824+ {
825+ var file = await ItemViewModel . GetFileFromPathAsync ( item . ItemPath ) ;
823826
824- App . JumpList . RemoveFolder ( folder . Path ) ;
827+ await file . RenameAsync ( newName , NameCollisionOption . GenerateUniqueName ) ;
828+ }
825829 }
826- else
830+ else if ( result == ContentDialogResult . Secondary )
827831 {
828- var file = await ItemViewModel . GetFileFromPathAsync ( item . ItemPath ) ;
832+ if ( item . PrimaryItemAttribute == StorageItemTypes . Folder )
833+ {
834+ var folder = await ItemViewModel . GetFolderFromPathAsync ( item . ItemPath ) ;
835+
836+ await folder . RenameAsync ( newName , NameCollisionOption . ReplaceExisting ) ;
837+
838+ App . JumpList . RemoveFolder ( folder . Path ) ;
839+ }
840+ else
841+ {
842+ var file = await ItemViewModel . GetFileFromPathAsync ( item . ItemPath ) ;
829843
830- await file . RenameAsync ( newName , NameCollisionOption . ReplaceExisting ) ;
844+ await file . RenameAsync ( newName , NameCollisionOption . ReplaceExisting ) ;
845+ }
831846 }
832847 }
833848 }
0 commit comments