using System.Diagnostics;
if (Process.GetProcessesByName("CalculatorApp").Length > 0)
Console.WriteLine("калькулятор запущен");
else
Console.WriteLine("калькулятор не запущен");
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace ff.links
{
static partial class Program
{
static IEnumerable<string> scan(this IEnumerable<string> ds)
{
var files = new List<string>();
foreach (var d in ds)
try { files.add2my(d.here()).add2my(d.subdirs()); }
catch (Exception e) { Console.WriteLine($"{pfx}Scan \"{d}\" - {e.Message}"); }
return files;
}
static List<string> add2my(this List<string> l, IEnumerable<string> r) { l.AddRange(r); return l; }
static IEnumerable<string> here(this string d) => Directory.EnumerateFiles(d).Where(f => f.isTarget());
static IEnumerable<string> subdirs(this string d) => Directory.EnumerateDirectories(d).Where(p => !p.isIgnored()).scan();
static void print(this string s, string pfx = "", string sfx = "") => Console.WriteLine(pfx + s + sfx);
static void print(this IEnumerable<string> sa, string pfx = "", string sfx = "") => sa.ToList().ForEach(s => s.print(pfx, sfx));
static bool isTarget(this string p) => targets.Contains(p.Split(backSlashDelimiter).Last());
static string[] targets => new string[] { ffBinary, ffProfileSign, fflConfig };
const string fflConfig = "ff.links.cfg.json";
const string ffBinary = "firefox.exe";
const string ffProfileSign = "compatibility.ini";
const string skipd = ".default";
static bool isIgnored(this string p) => ignored.Contains(p.Split(backSlashDelimiter, StringSplitOptions.RemoveEmptyEntries).Last());
static string[] ignored => new string[]
{
"TorBrowser", "Microsoft", "MICROSOFT", "WindowsApps", "Windows", "WINDOWS",
"ProgramData", "All Users", "Documents and Settings", //"Users",
"My Documents", "My Pictures", "My Music", "My Videos", "Application Data",
"Start Menu", "Local Settings", "Cookies", "NetHood", "PrintHood", "Recent", "SendTo", "Templates",
"CrashReports", "WindowsImageBackup", "System Volume Information", "$Recycle.Bin", "$RECYCLE.BIN",
"root", "Default User"
};
static char[] backSlashDelimiter = new char[] { backSlash };
const char backSlash = '\\';
static IEnumerable<string> fromRoot() => Environment.GetLogicalDrives().Where(p => !p.isIgnored());
static IEnumerable<string> fromSysDrive() { yield return @"c:\"; }
static IEnumerable<string> fromTypical()
{
var path = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)}\Mozilla Firefox";
yield return path;
int p;
if ((p=path.IndexOf(" (x86)")) >= 0)
yield return path = path.Remove(p, 6);
path = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\Mozilla\Firefox\Profiles";
yield return path;
}
}
}
using System;
using System.Diagnostics;
using System.Linq;
namespace ff.links
{
static partial class Program
{
static void Main(string[] args)
{
var sw = new Stopwatch();
sw.Start();
"let's begin...".print();
var finds = fromTypical().scan();
"found targets is ".print(pfx, finds.Count().ToString());
//finds.print();
var bro = finds.Where(b => b.Contains(ffBinary));
"found browsers is ".print(pfx, bro.Count().ToString());
bro.print(pfx);
var cfg = finds.Where(b => b.Contains(fflConfig));
"found configs is ".print(pfx, cfg.Count().ToString());
cfg.print(pfx);
var profiles = finds.Where(b => (b.Contains(ffProfileSign) && !b.Contains(skipd)));
"found profiles is ".print(pfx, profiles.Count().ToString());
//profiles.print();
profiles.buildLinks(bro.First());
//profiles.prefsApplay();
//links2start();
sw.Stop();
var ts = sw.Elapsed;
$"RunTime {ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds:000}".print();
//#if DEBUG
// "press any key to continue...".print();
// Console.ReadKey();
//#endif
}
const string pfx = " ::> ";
}
}
var finds = @"C:\".scan();
Class A : B
или наоборотClass B : A
эту версию как раз надо проверятьobject A
dynamic A
но риски гимора такие же /ppsWindows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\Scan_Content]
@="Show Usage with Scanner"
"Icon"="c:\\bin\\scn2\\Scanner.exe"
[HKEY_CLASSES_ROOT\Directory\shell\Scan_Content\command]
@="c:\\bin\\scn2\\Scanner.exe \"%1\""
[HKEY_CLASSES_ROOT\Drive\shell\Scan_Content]
@="Show Usage with Scanner"
"Icon"="c:\\bin\\scn2\\Scanner.exe"
[HKEY_CLASSES_ROOT\Drive\shell\Scan_Content\command]
@="c:\\bin\\scn2\\Scanner.exe \"%1\""
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\Directory\shell\Scan_Content]
[-HKEY_CLASSES_ROOT\Directory\shell\Scan_Content\command]
[-HKEY_CLASSES_ROOT\Drive\shell\Scan_Content]
[-HKEY_CLASSES_ROOT\Drive\shell\Scan_Content\command]