@@ -363,22 +363,18 @@ public unsafe (string? v, Exception? ex) FileNameInfo
363363 int bufferLength = ( int ) ( fni . FileNameLength + Marshal . SizeOf ( fni ) ) ;
364364 using SafeBuffer < FILE_NAME_INFO > safeBuffer = new ( numBytes : ( nuint ) bufferLength ) ;
365365
366- if ( GetFileInformationByHandleEx ( this , FILE_INFO_BY_HANDLE_CLASS . FileNameInfo , ( FILE_NAME_INFO * ) safeBuffer . DangerousGetHandle ( ) , ( uint ) bufferLength ) )
367- {
368- UNICODE_STRING str = new ( )
369- {
370- Buffer = new PWSTR ( ( char * ) safeBuffer . DangerousGetHandle ( ) ) ,
371- Length = ( ushort ) fni . FileNameLength ,
372- MaximumLength = ( ushort ) bufferLength
373- } ;
366+ if ( ! GetFileInformationByHandleEx ( this , FILE_INFO_BY_HANDLE_CLASS . FileNameInfo , ( FILE_NAME_INFO * ) safeBuffer . DangerousGetHandle ( ) , ( uint ) bufferLength ) )
367+ return fileNameInfo = ( null , new Exception ( errFailedMsg + "GetFileInformationByHandleEx encountered an error." , new Win32Exception ( ) ) ) ;
374368
375- /* The string conversion copies the data to a new string in the managed heap before freeing safeBuffer and leaving this context. */
376- return fileNameInfo = ( ( string ) str , null ) ;
377- }
378- else
369+ UNICODE_STRING str = new ( )
379370 {
380- return fileNameInfo = ( null , new Exception ( errFailedMsg + "GetFileInformationByHandleEx encountered an error." , new Win32Exception ( ) ) ) ;
381- }
371+ Buffer = new PWSTR ( ( char * ) safeBuffer . DangerousGetHandle ( ) ) ,
372+ Length = ( ushort ) fni . FileNameLength ,
373+ MaximumLength = ( ushort ) bufferLength
374+ } ;
375+
376+ /* The string conversion copies the data to a new string in the managed heap before freeing safeBuffer and leaving this context. */
377+ return fileNameInfo = ( ( string ) str , null ) ;
382378 }
383379 else
384380 {
0 commit comments