@@ -211,21 +211,21 @@ private void ModernShellPage_BackNavRequested(object sender, EventArgs e)
211
211
212
212
private async void SidebarControl_RecycleBinItemRightTapped ( object sender , EventArgs e )
213
213
{
214
- var value = new ValueSet
214
+ var recycleBinHasItems = false ;
215
+ if ( ServiceConnection != null )
216
+ {
217
+ var value = new ValueSet
215
218
{
216
219
{ "Arguments" , "RecycleBin" } ,
217
220
{ "action" , "Query" }
218
221
} ;
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
+ }
228
227
}
228
+ SidebarControl . RecycleBinHasItems = recycleBinHasItems ;
229
229
}
230
230
231
231
private async void SidebarControl_SidebarItemDropped ( object sender , Controls . SidebarItemDroppedEventArgs e )
@@ -1146,16 +1146,11 @@ public void Up_Click()
1146
1146
Frame instanceContentFrame = ContentFrame ;
1147
1147
FilesystemViewModel . CancelLoadAndClearFiles ( ) ;
1148
1148
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 )
1156
1152
{
1157
- var currentPathWithoutEndingSlash = instance . WorkingDirectory . Remove ( instance . WorkingDirectory . LastIndexOf ( "\\ " ) ) ;
1158
- parentDirectoryOfPath = currentPathWithoutEndingSlash . Remove ( currentPathWithoutEndingSlash . LastIndexOf ( "\\ " ) ) ;
1153
+ parentDirectoryOfPath = instance . WorkingDirectory . Remove ( lastSlashIndex ) ;
1159
1154
}
1160
1155
1161
1156
SelectSidebarItemFromPath ( ) ;
0 commit comments