mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix System.ArgumentException
Fix System.ArgumentException("Illegal characters in path") when parsing
path string
This commit is contained in:
parent
cfeb637685
commit
f3038e4fef
1 changed files with 26 additions and 12 deletions
|
|
@ -1,21 +1,21 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Wox.Infrastructure.Logger;
|
||||||
|
|
||||||
namespace Wox.Plugin.Program.ProgramSources
|
namespace Wox.Plugin.Program.ProgramSources
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
[global::System.ComponentModel.Browsable(false)]
|
[System.ComponentModel.Browsable(false)]
|
||||||
public class AppPathsProgramSource: AbstractProgramSource
|
public class AppPathsProgramSource : AbstractProgramSource
|
||||||
{
|
{
|
||||||
public AppPathsProgramSource()
|
public AppPathsProgramSource()
|
||||||
{
|
{
|
||||||
this.BonusPoints = -10;
|
BonusPoints = -10;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppPathsProgramSource(ProgramSource source)
|
public AppPathsProgramSource(ProgramSource source) : this()
|
||||||
: this()
|
|
||||||
{
|
{
|
||||||
this.BonusPoints = source.BonusPoints;
|
BonusPoints = source.BonusPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override List<Program> LoadPrograms()
|
public override List<Program> LoadPrograms()
|
||||||
|
|
@ -33,17 +33,31 @@ namespace Wox.Plugin.Program.ProgramSources
|
||||||
if (root == null) return;
|
if (root == null) return;
|
||||||
foreach (var item in root.GetSubKeyNames())
|
foreach (var item in root.GetSubKeyNames())
|
||||||
{
|
{
|
||||||
using (var key = root.OpenSubKey(item))
|
try
|
||||||
{
|
{
|
||||||
object path = key.GetValue("");
|
using (var key = root.OpenSubKey(item))
|
||||||
if (path is string && global::System.IO.File.Exists((string)path))
|
|
||||||
{
|
{
|
||||||
var entry = CreateEntry((string)path);
|
string path = key.GetValue("") as string;
|
||||||
|
if (path == null) continue;
|
||||||
|
|
||||||
|
// fix path like this ""\"C:\\folder\\executable.exe\"""
|
||||||
|
const int begin = 0;
|
||||||
|
int end = path.Length - 1;
|
||||||
|
const char quotationMark = '"';
|
||||||
|
if (path[begin] == quotationMark && path[end] == quotationMark)
|
||||||
|
{
|
||||||
|
path = path.Substring(begin + 1, path.Length - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!System.IO.File.Exists(path)) continue;
|
||||||
|
var entry = CreateEntry(path);
|
||||||
entry.ExecuteName = item;
|
entry.ExecuteName = item;
|
||||||
list.Add(entry);
|
list.Add(entry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
key.Close();
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error(e.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue