Here are the examples of the csharp api System.IO.Directory.GetDirectories(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1328 Examples
19
Source : FileSystemUserData.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public override T[] LoadAll<T>() {
lock (GlobalLock) {
if (!Directory.Exists(UserRoot))
return Dummy<T>.EmptyArray;
string name = GetDataFileName(typeof(T));
return Directory.GetDirectories(UserRoot).Select(dir => LoadRaw<T>(Path.Combine(dir, name))).ToArray();
}
}
19
Source : FileSystemUserData.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public override string[] GetAll()
=> !Directory.Exists(UserRoot) ? Dummy<string>.EmptyArray : Directory.GetDirectories(UserRoot).Select(name => Path.GetFileName(name)).ToArray();
19
Source : FileSystemUserData.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public override int GetAllCount()
=> Directory.GetDirectories(UserRoot).Length;
19
Source : FileSystemHelper.cs
with zlib License
from 0x0ade
with zlib License
from 0x0ade
public static string[] GetDirectories(string path) {
string[] results;
if (_CachedDirectories.TryGetValue(path, out results))
return results;
try {
results = Directory.GetDirectories(path);
} catch {
results = null;
}
_CachedDirectories[path] = results;
return results;
}
19
Source : Chromium.cs
with GNU General Public License v3.0
from 0xfd3
with GNU General Public License v3.0
from 0xfd3
private static List<string> GetAllProfiles(string DirectoryPath)
{
List<string> loginDataFiles = new List<string>
{
DirectoryPath + @"\Default\Login Data",
DirectoryPath + @"\Login Data"
};
if (Directory.Exists(DirectoryPath))
{
foreach (string dir in Directory.GetDirectories(DirectoryPath))
{
if (dir.Contains("Profile"))
loginDataFiles.Add(dir + @"\Login Data");
}
}
return loginDataFiles;
}
19
Source : ModuleCollection.cs
with MIT License
from 17MKH
with MIT License
from 17MKH
public void Load()
{
var modulesRootPath = Path.Combine(AppContext.BaseDirectory, Constants.ROOT_DIR);
if (!Directory.Exists(modulesRootPath))
return;
var moduleDirs = Directory.GetDirectories(modulesRootPath);
if (!moduleDirs.Any())
return;
_replacedemblyHelper = new replacedemblyHelper();
var optionsList = new List<ModuleOptions>();
foreach (var dir in moduleDirs)
{
var code = Path.GetFileName(dir)!.Split("_")[1];
var options = _configuration.Get<ModuleOptions>($"Mkh:Modules:{code}");
if (options.Db != null)
{
options.Code = code;
options.Dir = dir;
optionsList.Add(options);
}
}
foreach (var options in optionsList.OrderBy(m => m.Sort))
{
LoadModule(options);
}
//释放资源
_replacedemblyHelper = null;
}
19
Source : Utils.cs
with Apache License 2.0
from 214175590
with Apache License 2.0
from 214175590
public static void CopyDir(string fromDir, string toDir)
{
if (!Directory.Exists(fromDir))
return;
if (!Directory.Exists(toDir))
{
Directory.CreateDirectory(toDir);
}
string[] files = Directory.GetFiles(fromDir);
foreach (string formFileName in files)
{
string fileName = Path.GetFileName(formFileName);
string toFileName = Path.Combine(toDir, fileName);
File.Copy(formFileName, toFileName);
}
string[] fromDirs = Directory.GetDirectories(fromDir);
foreach (string fromDirName in fromDirs)
{
string dirName = Path.GetFileName(fromDirName);
string toDirName = Path.Combine(toDir, dirName);
CopyDir(fromDirName, toDirName);
}
}
19
Source : UCGeneratedCode.cs
with MIT License
from 2881099
with MIT License
from 2881099
void InitTemplates()
{
string path = Path.Combine(Environment.CurrentDirectory, "Templates");
string[] dir = Directory.GetDirectories(path);
DirectoryInfo fdir = new DirectoryInfo(path);
FileInfo[] file = fdir.GetFiles("*.tpl");
if (file.Length != 0 || dir.Length != 0)
{
foreach (FileInfo f in file)
{
lst.Add(f);
}
}
if (lst.Count >= 1)
{
comboBoxEx1.DataSource = lst.Select(a => a.Name).ToArray();
comboBoxEx1.SelectedIndex = 0;
editorTemplates.Load(lst.FirstOrDefault().FullName);
}
}
19
Source : FrmBatch.cs
with MIT License
from 2881099
with MIT License
from 2881099
void loadTemplates()
{
string path = Path.Combine(Environment.CurrentDirectory, "Templates");
string[] dir = Directory.GetDirectories(path);
DirectoryInfo fdir = new DirectoryInfo(path);
FileInfo[] file = fdir.GetFiles("*.tpl");
if (file.Length != 0 || dir.Length != 0)
{
foreach (FileInfo f in file)
{
lst.Add(f);
listBoxAdv3.Items.Add(f.Name);
}
}
}
19
Source : FrmRazorTemplates.cs
with MIT License
from 2881099
with MIT License
from 2881099
void loadTemplates()
{
string path = Path.Combine(Environment.CurrentDirectory, "Templates");
string[] dir = Directory.GetDirectories(path);
DirectoryInfo fdir = new DirectoryInfo(path);
FileInfo[] file = fdir.GetFiles("*.tpl");
if (file.Length != 0 || dir.Length != 0)
{
foreach (FileInfo f in file)
{
lst.Add(f);
}
}
if (lst.Count >= 1)
{
comboBoxEx1.DataSource = lst.Select(a => a.Name).ToArray();
comboBoxEx1.SelectedIndex = 0;
}
}
19
Source : TemplateGenerator.cs
with MIT License
from 2881099
with MIT License
from 2881099
void BuildEachDirectory(string templateDirectory, string outputDirectory, TemplateEngin tpl, IDbFirst dbfirst, List<DbTableInfo> tables) {
if (Directory.Exists(outputDirectory) == false) Directory.CreateDirectory(outputDirectory);
var files = Directory.GetFiles(templateDirectory);
foreach (var file in files) {
var fi = new FileInfo(file);
if (string.Compare(fi.Extension, ".FreeSql", true) == 0) {
var outputExtension = "." + fi.Name.Split('.')[1];
if (fi.Name.StartsWith("for-table.")) {
foreach (var table in tables) {
var result = tpl.RenderFile(file, new Dictionary<string, object>() { { "table", table }, { "dbfirst", dbfirst } });
if (result.EndsWith("return;")) continue;
var outputName = table.Name + outputExtension;
var mcls = Regex.Match(result, @"\s+clreplaced\s+(\w+)");
if (mcls.Success) outputName = mcls.Groups[1].Value + outputExtension;
var outputStream = Encoding.UTF8.GetBytes(result);
var fullname = outputDirectory + "/" + outputName;
if (File.Exists(fullname)) File.Delete(fullname);
using (var outfs = File.Open(fullname, FileMode.OpenOrCreate, FileAccess.Write)) {
outfs.Write(outputStream, 0, outputStream.Length);
outfs.Close();
}
}
continue;
} else {
var result = tpl.RenderFile(file, new Dictionary<string, object>() { { "tables", tables }, { "dbfirst", dbfirst } });
var outputName = fi.Name;
var mcls = Regex.Match(result, @"\s+clreplaced\s+(\w+)");
if (mcls.Success) outputName = mcls.Groups[1].Value + outputExtension;
var outputStream = Encoding.UTF8.GetBytes(result);
var fullname = outputDirectory + "/" + outputName;
if (File.Exists(fullname)) File.Delete(fullname);
using (var outfs = File.Open(fullname, FileMode.OpenOrCreate, FileAccess.Write)) {
outfs.Write(outputStream, 0, outputStream.Length);
outfs.Close();
}
}
}
File.Copy(file, outputDirectory + file.Replace(templateDirectory, ""), true);
}
var dirs = Directory.GetDirectories(templateDirectory);
foreach(var dir in dirs) {
BuildEachDirectory(dir, outputDirectory + dir.Replace(templateDirectory, ""), tpl, dbfirst, tables);
}
}
19
Source : BeatmapConverter.cs
with MIT License
from 39M
with MIT License
from 39M
static void Convert()
{
Debug.Log(string.Format("Source path: {0}", beatmapPath));
// 每个目录代表一首歌,里面按字典序放置至多三个谱面,依次为 Easy, Normal, Hard
string[] sourceDirectories = Directory.GetDirectories(beatmapPath);
foreach (string directoryPath in sourceDirectories)
{
Music music = new Music();
// 遍历单个目录下的所有 osu 文件,对每个文件创建一个 Beatmap 对象,加到 Music 对象里面
string[] sourceFiles = Directory.GetFiles(directoryPath, "*.osu");
int count = 0;
foreach (string filepath in sourceFiles)
{
string[] lines = File.ReadAllLines(filepath);
Beatmap beatmap = new Beatmap();
music.beatmapList.Add(beatmap);
#region Set Difficulty
beatmap.difficultyName = difficultyNames[Mathf.Min(count, difficultyNames.Length - 1)];
beatmap.difficultyDisplayColor = new SimpleColor(difficultyColors[Mathf.Min(count, difficultyNames.Length - 1)]);
count++;
#endregion
#region Processing file line by line
bool startProcessNotes = false;
foreach (string line in lines)
{
if (line.StartsWith("[HitObjects]"))
{
startProcessNotes = true;
continue;
}
if (!startProcessNotes)
{
// 处理谱面信息
int lastIndex = line.LastIndexOf(':');
if (lastIndex < 0)
{
// 如果不是有效信息行则跳过
continue;
}
string value = line.Substring(lastIndex + 1).Trim();
if (line.StartsWith("replacedle"))
{
music.replacedle = value;
}
else if (line.StartsWith("Artist"))
{
music.artist = value;
}
else if (line.StartsWith("AudioFilename"))
{
value = value.Remove(value.LastIndexOf('.'));
music.audioFilename = value;
music.bannerFilename = value;
music.soundEffectFilename = value;
}
else if (line.StartsWith("PreviewTime"))
{
music.previewTime = float.Parse(value) / 1000;
}
else if (line.StartsWith("Creator"))
{
beatmap.creator = value;
}
else if (line.StartsWith("Version"))
{
beatmap.version = value;
}
}
else
{
// 开始处理 HitObject
string[] noteInfo = line.Split(',');
int type = int.Parse(noteInfo[3]);
if ((type & 0x01) != 0)
{
// Circle
beatmap.noteList.Add(new Note
{
x = int.Parse(noteInfo[0]),
y = int.Parse(noteInfo[1]),
time = float.Parse(noteInfo[2]) / 1000,
// 其他 Circle 相关的处理
});
}
else if ((type & 0x02) != 0)
{
// Slider
beatmap.noteList.Add(new Note
{
x = int.Parse(noteInfo[0]),
y = int.Parse(noteInfo[1]),
time = float.Parse(noteInfo[2]) / 1000,
// 其他 Slider 相关的处理
});
}
else if ((type & 0x08) != 0)
{
// Spinner
beatmap.noteList.Add(new Note
{
x = int.Parse(noteInfo[0]),
y = int.Parse(noteInfo[1]),
time = float.Parse(noteInfo[2]) / 1000,
// 其他 Spinner 相关的处理
});
beatmap.noteList.Add(new Note
{
x = int.Parse(noteInfo[0]),
y = int.Parse(noteInfo[1]),
time = float.Parse(noteInfo[5]) / 1000,
// 其他 Spinner 相关的处理
});
}
}
}
#endregion
}
string targetPath = directoryPath + ".json";
if (File.Exists(targetPath))
{
File.Delete(targetPath);
}
File.WriteAllText(targetPath, music.ToJson());
Debug.Log(string.Format("Converted osu! beatmap\n[{0}]\nto json file\n[{1}]", directoryPath, targetPath));
}
Debug.Log(string.Format("All done, converted {0} files.", sourceDirectories.Length));
}
19
Source : ExtendableEnums.cs
with MIT License
from 7ark
with MIT License
from 7ark
static KeyValuePair<string, string> FindAllScriptFiles(string startDir, string enumToFind)
{
try
{
foreach (string file in Directory.GetFiles(startDir))
{
if ((file.Contains(".cs") || file.Contains(".js")) && !file.Contains(".meta"))
{
string current = File.ReadAllText(file);
string currentTrimmed = current.Replace(" ", "").Replace("\n", "").Replace("\t", "").Replace("\r", "");
if (currentTrimmed.Contains(enumToFind.Replace(" ", "") + "{"))
return new KeyValuePair<string, string>(current, file);
}
}
foreach (string dir in Directory.GetDirectories(startDir))
{
KeyValuePair<string, string> result = FindAllScriptFiles(dir, enumToFind);
if (result.Key != "NOPE")
return result;
}
}
catch (System.Exception ex)
{
Debug.Log(ex.Message);
}
return new KeyValuePair<string, string>("NOPE", "NOPE");
}
19
Source : MainWindow.cs
with GNU General Public License v3.0
from a4004
with GNU General Public License v3.0
from a4004
private async void Init()
{
if (Program.Portable)
goto InitTaskEnd;
InitPyChk:
WaitFm.Caption("Checking if Python is installed");
await Task.Delay(1000);
if (!ShellManager.CheckCommand("py", "--version"))
{
WaitFm.Debug("Python could not be detected on your system. You can choose to install Python or use N2D22 in portable mode.", Event.Warning);
CreateRequest("Python isn't installed on this PC", "You can choose to install Python",
"Install Python 3.9.7 (Recommended)", "Portable mode (Legacy, not recommended)", out int result);
if (result == 1 /*install python*/)
{
WaitFm.Caption("Downloading Python x64 3.9.7");
try
{
WebClient client = new WebClient();
client.DownloadProgressChanged += (s, e) =>
{
WaitFm.Caption($"Downloading Python x64 3.9.7 from python.org ({e.ProgressPercentage}%)");
};
client.DownloadFileCompleted += delegate
{
WaitFm.Debug("Successfully downloaded python-3.9.7-amd64.exe from python.org", Event.Success);
WaitFm.Caption("Installing Python x64 3.9.7");
};
WaitFm.Debug("Downloading python-3.9.7-amd64.exe from python.org");
await client.DownloadFileTaskAsync("https://www.python.org/ftp/python/3.9.7/python-3.9.7-amd64.exe", "python-3.9.7-amd64.exe");
WaitFm.Caption("Installing Python");
WaitFm.Debug("Installing Python x64 3.9.7");
if (ShellManager.RunCommand(out string output, "python-3.9.7-amd64.exe", "/quiet InstallAllUsers=1 PrependPath=1"))
{
WaitFm.Caption("Verifying Python is installed");
WaitFm.Debug("Verifying Python x64 3.9.7", Event.Success);
WaitFm.replacedle("Preparing");
await Task.Delay(1000);
goto InitPyChk;
}
else
throw new Exception(output == default ? "Process not started." : output);
}
catch (Exception ex)
{
WaitFm.Debug($"Python could not be installed due to an error. {ex.Message}", Event.Critical);
await CreateMessage("We couldn't install Python", "Something went wrong during the install process. You can try again.");
WaitFm.Host.CloseTask();
WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
TaskManager.ReleaseFLock();
return;
}
}
else if (result == 2 /*run in portable mode*/)
{
Process.Start(Application.ExecutablePath, string.Join(" ", Environment.GetCommandLineArgs()) + " --portable");
Program.Terminate();
return;
}
else
throw new Exception($"The selection could not be determined due to an invalid value. {result}");
}
else
{
if (ShellManager.RunCommand(out string filePath, "py", "-c \"import sys; print(sys.executable)\""))
WaitFm.Debug($"Python is installed on this PC at \"{filePath}\".", Event.Success);
else
WaitFm.Debug("Could not get the executable path of the Python binary.", Event.Warning);
Program.Settings.PythonExe = filePath;
WaitFm.replacedle("Getting ready");
WaitFm.Caption("Checking for esptool.py");
await Task.Delay(1000);
if (!ShellManager.CheckCommand("py", "-m esptool --help"))
{
WaitFm.Debug("esptool.py isn't installed in the default Python environment. " +
"You can choose to install esptool or use N2D22 in portable mode.");
CreateRequest("esptool.py is missing", "You can choose to install it right now",
"Install esptool.py (Recommended)", "Portable mode (Legacy, not recommended)", out int result);
if (result == 1 /*install esptool*/)
{
WaitFm.Debug("Installing esptool.py");
WaitFm.Caption("Installing esptool.py");
if (ShellManager.RunCommand(out string output, "py", "-m pip install esptool"))
{
WaitFm.Debug("esptool.py was installed successfully.");
WaitFm.replacedle("Preparing");
await Task.Delay(3000);
goto InitPyChk;
}
}
else if (result == 2 /*run in portable mode*/)
{
Process.Start(Application.ExecutablePath, string.Join(" ", Environment.GetCommandLineArgs()) + " --portable");
Program.Terminate();
return;
}
else
throw new Exception($"The selection could not be determined due to an invalid value. {result}");
}
else
{
WaitFm.Caption("Making sure you're ready to flash");
WaitFm.Debug("esptool.py is installed in the default Python environment.");
Program.Settings.EsptoolPy = true;
await Task.Delay(1000);
WaitFm.Debug("Searching for device drivers.");
await Task.Delay(1000);
string silabserPath = Directory.GetDirectories(Environment.SystemDirectory + "\\DriverStore\\FileRepository\\")
.ToList().Where(o => o.Contains("silabser")).FirstOrDefault();
WaitFm.Debug($"Check \"{Environment.SystemDirectory}\\DriverStore\\FileRepository\\\" for \"silabser\"");
string ch34serPath = Directory.GetDirectories(Environment.SystemDirectory + "\\DriverStore\\FileRepository\\")
.ToList().Where(o => o.Contains("ch341ser")).FirstOrDefault();
WaitFm.Debug($"Check \"{Environment.SystemDirectory}\\DriverStore\\FileRepository\\\" for \"ch34ser\"");
string ftdiPortPath = Directory.GetDirectories(Environment.SystemDirectory + "\\DriverStore\\FileRepository\\")
.ToList().Where(o => o.Contains("ftdiport")).FirstOrDefault();
WaitFm.Debug($"Check \"{Environment.SystemDirectory}\\DriverStore\\FileRepository\\\" for \"ftdiport\"");
string ftdiBusPath = Directory.GetDirectories(Environment.SystemDirectory + "\\DriverStore\\FileRepository\\")
.ToList().Where(o => o.Contains("ftdibus")).FirstOrDefault();
WaitFm.Debug($"Check \"{Environment.SystemDirectory}\\DriverStore\\FileRepository\\\" for \"ftdibus\"");
if (silabserPath == default && ch34serPath == default && ftdiPortPath == default && ftdiBusPath == default)
{
WaitFm.Debug("Driver files not found in FileRepository.", Event.Warning);
await CreateMessage("Device drivers not found", "We could not detect any Espressif compatible device drivers " +
"on this PC. You can still try flashing your device as Windows may automatically install the correct drivers " +
"for you.", 10);
}
else if (silabserPath != default && ch34serPath != default && ftdiPortPath != default && ftdiBusPath != default)
{
WaitFm.Debug("Detected drivers: SILABSER, CH34SER, FTDIPORT-FTDIBUS", Event.Success);
await CreateMessage("Found multiple device drivers", "We found device drivers for Silicon Labs, CH34 and FTDI compatible " +
"devices on this PC. The correct driver will automatically take control of your device when flashing.", 10);
}
else
{
if (silabserPath != default)
{
WaitFm.Debug("Detected driver: SILABSER", Event.Success);
await CreateMessage("Found device driver (Silicon Labs)", "We found a device driver for Silicon Labs devices on this PC. " +
"Please ensure it is the correct driver for your device otherwise flashing might not work.", 5);
}
if (ch34serPath != default)
{
WaitFm.Debug("Detected driver: CH34SER", Event.Success);
await CreateMessage("Found device driver (CH34)", "We found a device driver for CH34 devices on this PC. " +
"Please ensure it is the correct driver for your device otherwise flashing might not work.", 5);
}
if (ftdiBusPath != default && ftdiPortPath != default)
{
WaitFm.Debug("Detected driver: FTDIPORT-FTDIBUS", Event.Success);
await CreateMessage("Found device driver (FTDI)", "We found a device driver for FTDI devices on this PC. " +
"Please ensure it is the correct driver for your device otherwise flashing might not work.", 5);
}
else if (ftdiBusPath != default || ftdiPortPath != default)
{
WaitFm.Debug($"Detected partial driver: {(ftdiPortPath != default ? "FTDIPORT" : ftdiBusPath != default ? "FTDIBUS" : "?")}", Event.Warning);
await CreateMessage("Found device driver files (FTDI)", "We found parts of a device driver package for FTDU " +
"devices on this PC. The driver might not be installed correctly. Ensure the driver is correct and/or " +
"installed correctly.", 7);
}
}
}
}
InitTaskEnd:
WaitFm.Caption("");
await Task.Delay(1000);
WaitFm.Host.CloseTask();
WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
TaskManager.ReleaseFLock();
if (Program.Settings.PortFix)
{
Invoke(new Action(() =>
{
mitigationNotice.Show();
CreateForegroundTask("devicescan-patch", new Task(delegate() { }), "", "Please connect your device to this PC. When you've confirmed it's connected, click Continue.");
}));
}
else
{
Invoke(new Action(() =>
{
CreateForegroundTask("devicescan", new Task(Search), "Searching for your device", "You should connect your device now");
}));
}
}
19
Source : DynamicDNAConverterBehaviourEditor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private void RecursiveScanFoldersForreplacedets(string path, Delegate callback, int addMethod)
{
var replacedetFiles = System.IO.Directory.GetFiles(path, "*.prefab");
foreach (var replacedetFile in replacedetFiles)
{
var tempDnaGO = replacedetDatabase.LoadreplacedetAtPath(replacedetFile, typeof(GameObject)) as GameObject;
DynamicDNAConverterBehaviour tempDnareplacedet = tempDnaGO.GetComponent<DynamicDNAConverterBehaviour>();
if (tempDnareplacedet)
{
callback.DynamicInvoke(tempDnareplacedet, addMethod);
}
}
foreach (var subFolder in System.IO.Directory.GetDirectories(path))
{
RecursiveScanFoldersForreplacedets(subFolder.Replace('\\', '/'), callback, addMethod);
}
}
19
Source : SlotLibraryEditor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private void RecursiveScanFoldersForreplacedets(string path)
{
var replacedetFiles = System.IO.Directory.GetFiles(path, "*.replacedet");
foreach (var replacedetFile in replacedetFiles)
{
var tempSlotDatareplacedet = replacedetDatabase.LoadreplacedetAtPath(replacedetFile, typeof(SlotDatareplacedet)) as SlotDatareplacedet;
if (tempSlotDatareplacedet)
{
AddSlotDatareplacedet(tempSlotDatareplacedet);
}
}
foreach (var subFolder in System.IO.Directory.GetDirectories(path))
{
RecursiveScanFoldersForreplacedets(subFolder.Replace('\\', '/'));
}
}
19
Source : UMAAssetIndexerEditor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private void RecursiveScanFoldersForreplacedets(string path)
{
var replacedetFiles = System.IO.Directory.GetFiles(path);
foreach (var replacedetFile in replacedetFiles)
{
string Extension = System.IO.Path.GetExtension(replacedetFile).ToLower();
if (Extension == ".replacedet" || Extension == ".controller" || Extension == ".txt")
{
Object o = replacedetDatabase.LoadMainreplacedetAtPath(replacedetFile);
if (o)
{
AddedDuringGui.Add(o);
}
}
}
foreach (var subFolder in System.IO.Directory.GetDirectories(path))
{
RecursiveScanFoldersForreplacedets(subFolder.Replace('\\', '/'));
}
}
19
Source : OverlayLibraryEditor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private void RecursiveScanFoldersForreplacedets(string path)
{
var replacedetFiles = System.IO.Directory.GetFiles(path, "*.replacedet");
foreach (var replacedetFile in replacedetFiles)
{
var tempOverlayData = replacedetDatabase.LoadreplacedetAtPath(replacedetFile, typeof(OverlayDatareplacedet)) as OverlayDatareplacedet;
if (tempOverlayData)
{
AddOverlayData(tempOverlayData);
}
}
foreach (var subFolder in System.IO.Directory.GetDirectories(path))
{
RecursiveScanFoldersForreplacedets(subFolder.Replace('\\', '/'));
}
}
19
Source : FolderTree.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
private static FoldersTree generateSubTree(string rootFolder)
{
var di = new DirectoryInfo(rootFolder);
var result = new FoldersTree() { directoryName = di.Name, SubDirs = new List<FoldersTree>() };
foreach (var dir in Directory.GetDirectories(rootFolder))
{
// var dirName = Path.Combine(rootFolder, dir);
var subTree = generateSubTree(dir);
result.SubDirs.Add(subTree);
}
return result;
}
19
Source : FileChecker.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public static List<ModelFileInfo> GenerateHashFiles(string rootFolder, Action<string, int> onStartUpdateFolder)
{
var result = new List<ModelFileInfo>();
if (string.IsNullOrEmpty(rootFolder) || !Directory.Exists(rootFolder))
{
Loger.Log($"Directory not found {rootFolder}");
return result;
}
generateHashFiles(result, ref rootFolder, rootFolder, true);
var checkFolders = Directory.GetDirectories(rootFolder);
// Файл который есть у клиента не найден, проверяем Первую директорию
for (var i = 0; i < checkFolders.Length; i++)
{
var folder = checkFolders[i];
onStartUpdateFolder?.Invoke(folder, i);
#if DEBUG
var di = new DirectoryInfo(folder);
if ("OnlineCity".Equals(di.Name))
continue;
#endif
var checkFolder = Path.Combine(rootFolder, folder);
if (Directory.Exists(checkFolder))
{
generateHashFiles(result, ref rootFolder, checkFolder);
}
else
{
Loger.Log($"Directory not found {checkFolder}");
}
}
return result;
}
19
Source : FileChecker.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
private static void generateHashFiles(List<ModelFileInfo> result, ref string rootFolder, string folder, bool level0 = false)
{
if (!level0)
{
var dirs = Directory.GetDirectories(folder);
foreach (var subDir in dirs)
{
generateHashFiles(result, ref rootFolder, subDir);
}
}
var files = Directory.GetFiles(folder);
int fileNamePos = rootFolder.Length + 1;
var computeHash = new FastComputeHash();
foreach (var file in files.Where(x => ApproveExt(x)))
{
var mfi = new ModelFileInfo()
{
FileName = file.Substring(fileNamePos)
};
GetCheckSum(mfi, file, computeHash);
#if DEBUG
/*
if (mfi.FileName.Contains("armony"))
{
Loger.Log($"generateHashFiles Harmony: {FileName} {Hash}");
}*/
#endif
result.Add(mfi);
}
computeHash.Wait();
}
19
Source : FileChecker.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public static byte[] CreateListFolder(string directory)
{
var dirs = Directory.GetDirectories(directory).OrderBy(x => x);
var sb = new StringBuilder();
foreach (var dir in dirs)
{
// только для дебага, а то папка Online city каждый раз обновляется
var di = new DirectoryInfo(dir);
#if DEBUG
if (di.Name.Equals("OnlineCity"))
continue;
#endif
sb.AppendLine(di.Name);
}
var txt = sb.ToString();
var diRoot = new DirectoryInfo(directory);
File.WriteAllText(Path.Combine(Loger.PathLog, diRoot.Name + ".txt"), txt);
return Encoding.ASCII.GetBytes(txt);
}
19
Source : UwpAppxBuildTools.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private static void UpdateDependenciesElement(XElement dependencies, XNamespace defaultNamespace)
{
var values = (PlayerSettings.WSATargetFamily[])Enum.GetValues(typeof(PlayerSettings.WSATargetFamily));
if (string.IsNullOrWhiteSpace(EditorUserBuildSettings.wsaUWPSDK))
{
var windowsSdkPaths = Directory.GetDirectories(@"C:\Program Files (x86)\Windows Kits\10\Lib");
for (int i = 0; i < windowsSdkPaths.Length; i++)
{
windowsSdkPaths[i] = windowsSdkPaths[i].Substring(windowsSdkPaths[i].LastIndexOf(@"\", StringComparison.Ordinal) + 1);
}
EditorUserBuildSettings.wsaUWPSDK = windowsSdkPaths[windowsSdkPaths.Length - 1];
}
string maxVersionTested = EditorUserBuildSettings.wsaUWPSDK;
if (string.IsNullOrWhiteSpace(EditorUserBuildSettings.wsaMinUWPSDK))
{
EditorUserBuildSettings.wsaMinUWPSDK = UwpBuildDeployPreferences.MIN_PLATFORM_VERSION.ToString();
}
string minVersion = EditorUserBuildSettings.wsaMinUWPSDK;
// Clear any we had before.
dependencies.RemoveAll();
foreach (PlayerSettings.WSATargetFamily family in values)
{
if (PlayerSettings.WSA.GetTargetDeviceFamily(family))
{
dependencies.Add(
new XElement(defaultNamespace + "TargetDeviceFamily",
new XAttribute("Name", $"Windows.{family}"),
new XAttribute("MinVersion", minVersion),
new XAttribute("MaxVersionTested", maxVersionTested)));
}
}
if (!dependencies.HasElements)
{
dependencies.Add(
new XElement(defaultNamespace + "TargetDeviceFamily",
new XAttribute("Name", "Windows.Universal"),
new XAttribute("MinVersion", minVersion),
new XAttribute("MaxVersionTested", maxVersionTested)));
}
}
19
Source : EditorProjectUtilities.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
internal static bool FindDirectory(string directoryPathToSearch, string directoryName, out string path)
{
path = string.Empty;
var directories = Directory.GetDirectories(directoryPathToSearch);
for (int i = 0; i < directories.Length; i++)
{
var name = Path.GetFileName(directories[i]);
if (name != null && name.Equals(directoryName))
{
path = directories[i];
return true;
}
if (FindDirectory(directories[i], directoryName, out path))
{
return true;
}
}
return false;
}
19
Source : OVRPluginUpdater.cs
with MIT License
from absurd-joy
with MIT License
from absurd-joy
private static List<PluginPackage> GetAllUtilitiesPluginPackages()
{
string pluginRootPath = GetUtilitiesPluginRootPath();
List<PluginPackage> packages = new List<PluginPackage>();
if (Directory.Exists(pluginRootPath))
{
var dirs = Directory.GetDirectories(pluginRootPath);
foreach(string dir in dirs)
{
packages.Add(GetPluginPackage(dir));
}
}
return packages;
}
19
Source : SmokeTests_ExampleWalkUsingBreadcrumbView.cs
with MIT License
from ABTSoftware
with MIT License
from ABTSoftware
private void RunExportExampleTest(ExampleStartTestCase testCase)
{
return;
// Useful UIAutomation Ids
// ExportExampleView
// ExportExampleView.ExportPathTextBox
// ExportExampleView.ExportButton
// ExportExampleView.CloseButton
// ExampleView.Export
// Toggle the export button, this shows ExportExampleView
var exportButton = _mainWindow.FindFirstDescendant("ExampleView.Export").AsToggleButton();
exportButton?.Toggle();
string exportPath = base.GetTemporaryDirectory();
try
{
var exampleExportView = WaitForElement(() => _mainWindow.FindFirstDescendant("ExportExampleView"));
var exampleExportTextBox = exampleExportView.FindFirstDescendant("ExportExampleView.ExportPathTextBox")
.AsTextBox();
var exampleExportButton =
exampleExportView.FindFirstDescendant("ExportExampleView.ExportButton").AsButton();
var exampleExportCloseButton =
exampleExportView.FindFirstDescendant("ExportExampleView.CloseButton").AsButton();
// Set output path and export
exampleExportTextBox.Text = exportPath;
exampleExportButton.Invoke();
// Get the messagebox, close it
var msg = WaitForElement(() => _mainWindow.ModalWindows.FirstOrDefault().AsWindow());
var yesButton = msg.FindFirstChild(cf => cf.ByName("OK")).AsButton();
yesButton.Invoke();
// Close example export view
exampleExportCloseButton?.Invoke();
// Now check the example
var subDir = Directory.GetDirectories(exportPath).First();
var projectFile = Directory.GetFiles(subDir, "*.sln").FirstOrDefault();
// MSBuild
//fs.WriteLine("@echo Building " + projectName);
//fs.WriteLine(@"call ""C:\Program Files (x86)\MSBuild\12.0\Bin\msbuild.exe"" /ToolsVersion:12.0 /p:Configuration=""Debug"" ""{0}/{0}.csproj"" /p:WarningLevel=0", projectName);
string msBuildPath = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin\\MSBuild.exe";
var msBuildProcess = Process.Start(new ProcessStartInfo(msBuildPath,
$"/ToolsVersion:Current /p:Configuration=\"Debug\" \"{projectFile}\" /t:Restore;Build /p:WarningLevel=0"));
msBuildProcess.WaitForExit(10000);
replacedert.That(msBuildProcess.ExitCode, Is.EqualTo(0), $"Failed to build example {testCase.Category}/{testCase.Group}/{testCase.Example}");
}
finally
{
Directory.Delete(exportPath, true);
}
}
19
Source : FSBuilder.cs
with Apache License 2.0
from acblog
with Apache License 2.0
from acblog
public static void EnsureDirectoryEmpty(string path)
{
EnsureDirectoryExists(path);
foreach (var v in Directory.GetFiles(path))
{
File.Delete(v);
}
foreach (var v in Directory.GetDirectories(path))
{
Directory.Delete(v, true);
}
}
19
Source : FSExtensions.cs
with Apache License 2.0
from acblog
with Apache License 2.0
from acblog
public static void CopyDirectory(string sourceDirPath, string saveDirPath)
{
if (!Directory.Exists(saveDirPath))
{
Directory.CreateDirectory(saveDirPath);
}
string[] files = Directory.GetFiles(sourceDirPath);
foreach (string file in files)
{
string pFilePath = Path.Join(saveDirPath, Path.GetFileName(file));
File.Copy(file, pFilePath, true);
}
string[] dirs = Directory.GetDirectories(sourceDirPath);
foreach (string dir in dirs)
{
CopyDirectory(dir, Path.Join(saveDirPath, Path.GetFileName(dir)));
}
}
19
Source : UpgradeTaskBase.cs
with MIT License
from Accelerider
with MIT License
from Accelerider
protected virtual IEnumerable<(Version Version, string Path)> GetLocalVersions()
{
return from folderPath in Directory.GetDirectories(InstallDirectory)
let folderName = Path.GetFileName(folderPath)
where !string.IsNullOrEmpty(folderName)
let match = _versionRegex.Match(folderName)
where match.Success
select (Version.Parse(match.Groups[1].Value), folderPath);
}
19
Source : Program.cs
with MIT License
from Accelerider
with MIT License
from Accelerider
private static IEnumerable<BinDirectory> GetBinDirectories(string path)
{
return from directory in Directory.GetDirectories(path)
let match = BinDirectoryRegex.Match(Path.GetFileName(directory) ?? string.Empty)
where match.Success
select new BinDirectory(Version.Parse(match.Groups[1].Value), directory);
}
19
Source : PipelineDirectoryManager.cs
with MIT License
from actions
with MIT License
from actions
public TrackingConfig PrepareDirectory(
IExecutionContext executionContext,
WorkspaceOptions workspace)
{
// Validate parameters.
Trace.Entering();
ArgUtil.NotNull(executionContext, nameof(executionContext));
var trackingManager = HostContext.GetService<ITrackingManager>();
var repoFullName = executionContext.GetGitHubContext("repository");
ArgUtil.NotNullOrEmpty(repoFullName, nameof(repoFullName));
// Load the existing tracking file if one already exists.
string trackingFile = Path.Combine(
HostContext.GetDirectory(WellKnownDirectory.Work),
Constants.Pipeline.Path.PipelineMappingDirectory,
repoFullName,
Constants.Pipeline.Path.TrackingConfigFile);
Trace.Info($"Loading tracking config if exists: {trackingFile}");
TrackingConfig trackingConfig = trackingManager.LoadIfExists(executionContext, trackingFile);
// Create a new tracking config if required.
if (trackingConfig == null)
{
Trace.Info("Creating a new tracking config file.");
trackingConfig = trackingManager.Create(
executionContext,
trackingFile);
ArgUtil.NotNull(trackingConfig, nameof(trackingConfig));
}
else
{
// For existing tracking config files, update the job run properties.
Trace.Info("Updating job run properties.");
trackingConfig.LastRunOn = DateTimeOffset.Now;
trackingManager.Update(executionContext, trackingConfig, trackingFile);
}
// Prepare the pipeline directory.
if (string.Equals(workspace?.Clean, PipelineConstants.WorkspaceCleanOptions.All, StringComparison.OrdinalIgnoreCase))
{
CreateDirectory(
executionContext,
description: "pipeline directory",
path: Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), trackingConfig.PipelineDirectory),
deleteExisting: true);
CreateDirectory(
executionContext,
description: "workspace directory",
path: Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), trackingConfig.WorkspaceDirectory),
deleteExisting: true);
}
else if (string.Equals(workspace?.Clean, PipelineConstants.WorkspaceCleanOptions.Resources, StringComparison.OrdinalIgnoreCase))
{
foreach (var repository in trackingConfig.Repositories)
{
CreateDirectory(
executionContext,
description: $"directory {repository.Value.RepositoryPath} for repository {repository.Key}",
path: Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), repository.Value.RepositoryPath),
deleteExisting: true);
}
}
else if (string.Equals(workspace?.Clean, PipelineConstants.WorkspaceCleanOptions.Outputs, StringComparison.OrdinalIgnoreCase))
{
var allDirectories = Directory.GetDirectories(Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), trackingConfig.PipelineDirectory)).ToList();
foreach (var repository in trackingConfig.Repositories)
{
allDirectories.Remove(Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), repository.Value.RepositoryPath));
}
foreach (var deleteDir in allDirectories)
{
executionContext.Debug($"Delete existing untracked directory '{deleteDir}'");
DeleteDirectory(executionContext, "untracked dir", deleteDir);
}
}
else
{
CreateDirectory(
executionContext,
description: "pipeline directory",
path: Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), trackingConfig.PipelineDirectory),
deleteExisting: false);
CreateDirectory(
executionContext,
description: "workspace directory",
path: Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), trackingConfig.WorkspaceDirectory),
deleteExisting: false);
}
return trackingConfig;
}
19
Source : MainControl.xaml.cs
with MIT License
from Actipro
with MIT License
from Actipro
private void QueueFolder(List<string> queuedFiles, string path) {
this.QueueFiles(queuedFiles, path, "*.cs");
this.QueueFiles(queuedFiles, path, "*.vb");
this.QueueFiles(queuedFiles, path, "*.xaml");
string[] childFolders = Directory.GetDirectories(path);
if (childFolders != null) {
foreach (string childFolder in childFolders)
this.QueueFolder(queuedFiles, childFolder);
}
}
19
Source : Program.cs
with GNU General Public License v3.0
from AdisonCavani
with GNU General Public License v3.0
from AdisonCavani
Dictionary<string, string> DirectoriesDictionary(string directoryPath, string repoPath)
{
var dirsArray = Directory.GetDirectories(directoryPath);
return dirsArray.ToDictionary(key => key, value => value.Substring(value.IndexOf(@"customize\") + 10));
}
19
Source : Program.cs
with GNU General Public License v3.0
from AdisonCavani
with GNU General Public License v3.0
from AdisonCavani
string[] DirectoriesArray(string directoryPath)
{
return Directory.GetDirectories(directoryPath);
}
19
Source : Program.cs
with GNU General Public License v3.0
from AdriaandeJongh
with GNU General Public License v3.0
from AdriaandeJongh
static void SearchFilesInDirectory(string targetDirectory, List<string> fileList)
{
string[] fileEntries = Directory.GetFiles(targetDirectory);
foreach (string fileName in fileEntries)
fileList.Add(fileName);
string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
foreach (string subdirectory in subdirectoryEntries)
SearchFilesInDirectory(subdirectory, fileList);
}
19
Source : FolderRegPickerWindow.xaml.cs
with MIT License
from advancedmonitoring
with MIT License
from advancedmonitoring
private void folder_OnExpanded(object sender, RoutedEventArgs e)
{
var item = (TreeViewItem) sender;
try
{
if (item.Items.Count == 1 && (item.Items[0] is TreeViewItem) && ( string.IsNullOrWhiteSpace((string)((TreeViewItem)item.Items[0]).Header)))
{
EdtPath.Text = item.Tag.ToString().Trim();
item.Items.Clear();
try
{
foreach (var s in Directory.GetDirectories(item.Tag.ToString()))
{
var subitem = new TreeViewItem
{
Header = s.Substring(s.LastIndexOf("\\") + 1),
Tag = s
};
try
{
if (Directory.GetDirectories(s).Length != 0)
subitem.Items.Add(new TreeViewItem {Header = ""});
}
catch { /* ignore */ }
subitem.Expanded += folder_OnExpanded;
subitem.Selected += element_OnSelected;
item.Items.Add(subitem);
}
}
catch { /* ignore */ }
}
}
catch { /* ignore */ }
}
19
Source : Util.cs
with MIT License
from Aeroblast
with MIT License
from Aeroblast
public static void DeleteEmptyDir(string path)
{
if (!Directory.Exists(path)) return;
foreach (string p in Directory.GetDirectories(path)) DeleteEmptyDir(p);
if (Directory.GetDirectories(path).Length == 0 && Directory.GetFiles(path).Length == 0)
Directory.Delete(path);
}
19
Source : Util.cs
with MIT License
from Aeroblast
with MIT License
from Aeroblast
public static void DeleteDir(string path)
{
if (!Directory.Exists(path)) return;
foreach (string p in Directory.GetFiles(path)) File.Delete(p);
foreach (string p in Directory.GetDirectories(path)) DeleteDir(p);
Directory.Delete(path);
}
19
Source : Program.cs
with GNU General Public License v3.0
from Aeroblast
with GNU General Public License v3.0
from Aeroblast
static void ProcBatch(string[] args)
{
Log.log("Batch Process:" + args[0]);
string[] dirs = Directory.GetDirectories(args[0]);
foreach (string s in dirs)
{
if (!s.Contains("EBOK")) continue;
string[] args2 = new string[2];
args2[0] = s;
if (args.Length >= 2 && Directory.Exists(args[1])) args2[1] = args[1];
else args2[1] = Environment.CurrentDirectory;
try { ProcPath(args2); } catch (Exception e) { Log.log(e.ToString()); }
}
end_of_proc = true;
}
19
Source : IOHelper.cs
with Mozilla Public License 2.0
from agebullhu
with Mozilla Public License 2.0
from agebullhu
private static void GetAllFiles(List<string> fields, string path, string ext)
{
if (!Directory.Exists(path))
{
return;
}
fields.AddRange(Directory.GetFiles(path, ext, SearchOption.TopDirectoryOnly));
foreach (var ch in Directory.GetDirectories(path))
{
GetAllFiles(fields, ch, ext);
}
}
19
Source : IOHelper.cs
with Mozilla Public License 2.0
from agebullhu
with Mozilla Public License 2.0
from agebullhu
public static void DeleteDirectory(string directory, bool delete = true)
{
if (!Directory.Exists(directory))
{
return;
}
var ds = Directory.GetDirectories(directory);
foreach (var d in ds)
{
DeleteDirectory(d);
}
var fs = Directory.GetFiles(directory);
foreach (var f in fs)
{
File.Delete(f);
}
if (delete)
{
Directory.Delete(directory);
}
}
19
Source : IOHelper.cs
with Mozilla Public License 2.0
from agebullhu
with Mozilla Public License 2.0
from agebullhu
public static void CopyPath(string srcPath, string destPath, string ext = "*.*", bool child = true, bool replace = false, params string[] excludes)
{
if (!Directory.Exists(srcPath))
{
return;
}
CheckPath(destPath);
foreach (var ch in Directory.GetFiles(srcPath, ext))
{
if (excludes != null && excludes.Contains(Path.GetExtension(ch), StringComparer.OrdinalIgnoreCase))
{
continue;
}
var ch2 = Path.Combine(destPath, Path.GetFileName(ch));
if (replace || !File.Exists(ch2))
{
File.Copy(ch, ch2, true);
}
}
if (!child)
{
return;
}
foreach (var ch in Directory.GetDirectories(srcPath))
{
if (excludes != null && excludes.Contains(Path.GetFileName(ch), StringComparer.OrdinalIgnoreCase))
{
continue;
}
CopyPath(ch, Path.Combine(destPath, Path.GetFileName(ch) ?? throw new InvalidOperationException()), ext, true, replace, excludes);
}
}
19
Source : StickersExport.cs
with MIT License
from agens-no
with MIT License
from agens-no
public static void WriteToProject(string pathToBuiltProject)
{
var exists = Directory.Exists(pathToBuiltProject);
if (!exists)
{
LogError("Could not find directory '" + pathToBuiltProject + "'");
return;
}
var directories = Directory.GetDirectories(pathToBuiltProject);
if (directories.Length == 0)
{
LogError("Could not find any directories in the directory '" + pathToBuiltProject + "'");
return;
}
var pbxProjFile = directories.FirstOrDefault(file => Path.GetExtension(file) == ".pbxproj" || Path.GetExtension(file) == ".xcodeproj");
if (pbxProjFile == null)
{
var files = Directory.GetFiles(pathToBuiltProject);
if (files.Length == 0)
{
LogError("Could not find any files in the directory '" + pathToBuiltProject + "'");
return;
}
pbxProjFile = files.FirstOrDefault(file => Path.GetExtension(file) == ".pbxproj" || Path.GetExtension(file) == ".xcodeproj");
if (pbxProjFile == null)
{
LogError("Could not find the Xcode project in the directory '" + pathToBuiltProject + "'");
return;
}
}
var pack = EditorGUIUtility.Load(StickerreplacedetName) as StickerPack;
AddSticker(pack);
#if UNITY_5_6_OR_NEWER
var extensionBundleId = PlayerSettings.applicationIdentifier + "." + pack.BundleId;
#else
var extensionBundleId = PlayerSettings.bundleIdentifier + "." + pack.BundleId;
#endif
PBXProject.AddStickerExtensionToXcodeProject(
ExportPath + ExportName + "/",
pathToBuiltProject + "/",
ExportName,
extensionBundleId,
PlayerSettings.iOS.appleDeveloperTeamID,
PlayerSettings.bundleVersion,
PlayerSettings.iOS.buildNumber,
GetTargetDeviceFamily(PlayerSettings.iOS.targetDevice),
pack.Signing.AutomaticSigning,
pack.Signing.ProvisioningProfile,
pack.Signing.ProvisioningProfileSpecifier
);
Log("Added sticker extension named " + pack.replacedle);
}
19
Source : CacheManager.cs
with GNU General Public License v3.0
from aiportal
with GNU General Public License v3.0
from aiportal
public IEnumerable<SessionInfo> EnumSessions()
{
foreach (string dir in Directory.GetDirectories(CacheManager.CachePath))
{
SessionInfo si = null;
try
{
string rds = Path.Combine(dir, "0.rds");
if (File.Exists(rds))
si = SerializeEngine.Deserialize(rds) as SessionInfo;
}
catch (Exception ex) { TraceLogger.Instance.WriteException(ex); }
if (si != null)
yield return si;
}
}
19
Source : CacheManager.cs
with GNU General Public License v3.0
from aiportal
with GNU General Public License v3.0
from aiportal
public IEnumerable<SessionInfo> EnumSessions()
{
foreach (string dir in Directory.GetDirectories(CacheManager.CachePath))
{
SessionInfo si = null;
try
{
string rds = Path.Combine(dir, "0.rds");
if (File.Exists(rds))
si = SerializeEngine.Deserialize(rds) as SessionInfo;
}
catch (Exception ex) { TraceLogger.Instance.WriteException(ex); }
if (si != null)
{
string rde = Path.Combine(dir, "0.rde");
if (File.Exists(rde))
si.IsEnd = true;
yield return si;
}
}
}
19
Source : CacheManager.cs
with GNU General Public License v3.0
from aiportal
with GNU General Public License v3.0
from aiportal
public IEnumerable<SessionInfo> EnumSessions()
{
foreach (string dir in Directory.GetDirectories(CacheManager.CachePath))
{
SessionInfo si = null;
try
{
string rds = Path.Combine(dir, "0.rds");
if (File.Exists(rds))
si = SerializeEngine.Deserialize(rds) as SessionInfo;
}
catch (Exception ex) { TraceLog.WriteException(ex); }
if (si != null)
{
string rde = Path.Combine(dir, "0.rde");
if (File.Exists(rde))
si.IsEnd = true;
yield return si;
}
}
}
19
Source : mainForm.cs
with MIT License
from ajohns6
with MIT License
from ajohns6
public static void DeleteDirectory(string targetDir)
{
if (!Directory.Exists(targetDir)) return;
File.SetAttributes(targetDir, FileAttributes.Normal);
string[] files = Directory.GetFiles(targetDir);
string[] dirs = Directory.GetDirectories(targetDir);
foreach (string file in files)
{
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
}
foreach (string dir in dirs)
{
DeleteDirectory(dir);
}
Directory.Delete(targetDir, false);
}
19
Source : Paths.cs
with MIT License
from AkiniKites
with MIT License
from AkiniKites
private static void DeleteDirectoryNoCheck(string path)
{
File.SetAttributes(path, FileAttributes.Normal);
foreach (string file in Directory.GetFiles(path))
{
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
}
foreach (string dir in Directory.GetDirectories(path))
DeleteDirectory(dir);
Directory.Delete(path, false);
}
19
Source : MagicLaboratory.cs
with MIT License
from alaabenfatma
with MIT License
from alaabenfatma
public static string DeleteAllDirectoriesForce(string head, bool async = true)
{
if (DeletedFolders.Peek() == "End.")
foreach (var file in Directory.GetFiles(head))
File.Delete(file);
foreach (var h in Directory.GetDirectories(head))
DeleteAllDirectoriesForce(h);
Directory.Delete(head);
return null;
}
19
Source : CloudServiceFunctions.cs
with MIT License
from AlbertMN
with MIT License
from AlbertMN
public static string GetGoogleDriveFolder() {
//New Google Drive check first
string registryKey = @"Software\Google\DriveFS";
RegistryKey key = Registry.CurrentUser.OpenSubKey(registryKey);
if (key != null || Directory.Exists(Environment.ExpandEnvironmentVariables("%programfiles%") + @"\Google\Drive File Stream")) {
//New google Drive seems to be installed
DriveInfo[] allDrives = DriveInfo.GetDrives();
//Check if it's a virual drive
foreach (DriveInfo d in allDrives) {
if (d.VolumeLabel == "Google Drive") {
string check = Path.Combine(d.Name, "My Drive");
if (Directory.Exists(check)) {
return check;
}
}
}
//Not a virtual drive, check the user's folder
string userDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
if (Directory.Exists(userDir)) {
foreach (string dir in Directory.GetDirectories(userDir)) {
if (dir.Contains("My Drive")) {
//Pretty sure it's Google Drive... But bad practice maybe...?
return dir;
}
}
}
return "partial";
}
//No? Check the old one
registryKey = @"Software\Google\Drive";
key = Registry.CurrentUser.OpenSubKey(registryKey);
if (key != null) {
string installed = key.GetValue("Installed").ToString();
key.Close();
if (installed != null) {
if (installed == "True") {
string checkPath = Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "Google Drive");
if (Directory.Exists(checkPath)) {
return checkPath;
}
return "partial";
}
}
}
return "";
}
See More Examples