Update getting previous directory method

This commit is contained in:
Jeremy Wu 2020-05-26 21:47:47 +10:00
parent 355a787b5e
commit 3caafa325f

View file

@ -164,16 +164,16 @@ namespace Flow.Launcher.Plugin.SharedCommands
///<summary>
/// Gets the previous level directory from a path string.
/// Checks that previous level directory exists and returns it
/// as a path string, or empty string if doesnt exit
/// as a path string, or empty string if doesn't exit
///</summary>
public static string GetPreviousExistingDirectory(Func<string, bool> locationExists, string path)
{
var previousDirectoryPath = "";
int index = path.LastIndexOf('\\');
var index = path.LastIndexOf('\\');
if (index > 0 && index < (path.Length - 1))
{
previousDirectoryPath = path.Substring(0, index + 1);
if (!locationExists(path))
if (!locationExists(previousDirectoryPath))
{
return "";
}