@@ -211,21 +211,21 @@ private void ModernShellPage_BackNavRequested(object sender, EventArgs e)
211211
212212 private async void SidebarControl_RecycleBinItemRightTapped ( object sender , EventArgs e )
213213 {
214- var value = new ValueSet
214+ var recycleBinHasItems = false ;
215+ if ( ServiceConnection != null )
216+ {
217+ var value = new ValueSet
215218 {
216219 { "Arguments" , "RecycleBin" } ,
217220 { "action" , "Query" }
218221 } ;
219-
220- var response = await ServiceConnection . SendMessageAsync ( value ) ;
221- if ( response . Status == AppServiceResponseStatus . Success && response . Message . TryGetValue ( "NumItems" , out var numItems ) )
222- {
223- SidebarControl . RecycleBinHasItems = ( long ) numItems > 0 ;
224- }
225- else
226- {
227- SidebarControl . RecycleBinHasItems = false ;
222+ var response = await ServiceConnection . SendMessageAsync ( value ) ;
223+ if ( response . Status == AppServiceResponseStatus . Success && response . Message . TryGetValue ( "NumItems" , out var numItems ) )
224+ {
225+ recycleBinHasItems = ( long ) numItems > 0 ;
226+ }
228227 }
228+ SidebarControl . RecycleBinHasItems = recycleBinHasItems ;
229229 }
230230
231231 private async void SidebarControl_SidebarItemDropped ( object sender , Controls . SidebarItemDroppedEventArgs e )
@@ -1146,16 +1146,11 @@ public void Up_Click()
11461146 Frame instanceContentFrame = ContentFrame ;
11471147 FilesystemViewModel . CancelLoadAndClearFiles ( ) ;
11481148 var instance = FilesystemViewModel ;
1149- string parentDirectoryOfPath ;
1150- // Check that there isn't a slash at the end
1151- if ( ( instance . WorkingDirectory . Count ( ) - 1 ) - instance . WorkingDirectory . LastIndexOf ( "\\ " ) > 0 )
1152- {
1153- parentDirectoryOfPath = instance . WorkingDirectory . Remove ( instance . WorkingDirectory . LastIndexOf ( "\\ " ) ) ;
1154- }
1155- else // Slash found at end
1149+ string parentDirectoryOfPath = instance . WorkingDirectory . TrimEnd ( '\\ ' ) ;
1150+ var lastSlashIndex = parentDirectoryOfPath . LastIndexOf ( "\\ " ) ;
1151+ if ( lastSlashIndex != - 1 )
11561152 {
1157- var currentPathWithoutEndingSlash = instance . WorkingDirectory . Remove ( instance . WorkingDirectory . LastIndexOf ( "\\ " ) ) ;
1158- parentDirectoryOfPath = currentPathWithoutEndingSlash . Remove ( currentPathWithoutEndingSlash . LastIndexOf ( "\\ " ) ) ;
1153+ parentDirectoryOfPath = instance . WorkingDirectory . Remove ( lastSlashIndex ) ;
11591154 }
11601155
11611156 SelectSidebarItemFromPath ( ) ;
0 commit comments