Skip to content

Commit d91aeb6

Browse files
committed
When initialPath parameter points to a file, instead of using FileBrowser's default initial path, that file's parent directory will become the initial path
1 parent 67c98db commit d91aeb6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Plugins/SimpleFileBrowser/Scripts/FileBrowser.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,12 @@ private int CalculateLengthOfDropdownText( string str )
14901490

14911491
private string GetInitialPath( string initialPath )
14921492
{
1493+
if( !string.IsNullOrEmpty( initialPath ) && !Directory.Exists( initialPath ) && File.Exists( initialPath ) )
1494+
{
1495+
// Path points to a file, use its parent directory's path instead
1496+
initialPath = Path.GetDirectoryName( initialPath );
1497+
}
1498+
14931499
if( string.IsNullOrEmpty( initialPath ) || !Directory.Exists( initialPath ) )
14941500
{
14951501
if( CurrentPath.Length == 0 )

0 commit comments

Comments
 (0)