Here are the examples of the csharp api System.IO.DirectoryInfo.GetDirectories() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
933 Examples
19
View Source File : Form2.cs
License : MIT License
Project Creator : 200Tigersbloxed
License : MIT License
Project Creator : 200Tigersbloxed
void InstallMultiContinued()
{
statuslabel.Text = "Status: Extracting Files";
progressBar1.Value = 80;
DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Files");
foreach (FileInfo file in di.GetFiles())
{
string[] splitdot = file.Name.Split('.');
if (splitdot[1] == "zip")
{
ZipFile.ExtractToDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\" + splitdot[0] + @".zip", @"Files\" + splitdot[0]);
}
}
statuslabel.Text = "Status: Moving Files";
progressBar1.Value = 90;
foreach (DirectoryInfo dir in di.GetDirectories())
{
if (multiselected == "a")
{
if (dir.Name == "ca")
{
DirectoryInfo cadi = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Files\ca");
if (Directory.Exists(bsl + @"\CustomAvatars"))
{
// dont u dare delete someone's custom avatars folder
}
else
{
Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\ca\CustomAvatars", bsl + @"\CustomAvatars");
}
if (Directory.Exists(bsl + @"\DynamicOpenVR"))
{
Directory.Delete(bsl + @"\DynamicOpenVR", true);
Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\ca\DynamicOpenVR", bsl + @"\DynamicOpenVR");
}
else
{
Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\ca\DynamicOpenVR", bsl + @"\DynamicOpenVR");
}
foreach (DirectoryInfo cadir in cadi.GetDirectories())
{
if (cadir.Name == "Plugins")
{
// Don't move CustomAvatar's DLL
}
}
}
}
if(dir.Name == "dc")
{
DirectoryInfo dcdi = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"Files\dc");
foreach (DirectoryInfo dcdir in dcdi.GetDirectories())
{
if (dcdir.Name == "Plugins")
{
foreach (FileInfo file in dcdir.GetFiles())
{
if (File.Exists(bsl + @"\Plugins\" + file.Name)) {
File.Delete(bsl + @"\Plugins\" + file.Name);
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
}
}
if (dcdir.Name == "Libs")
{
foreach (DirectoryInfo dcnativedir in dcdir.GetDirectories())
{
if (Directory.Exists(bsl + @"\Libs\Native")) {
Directory.Delete(bsl + @"\Libs\Native", true);
Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\dc\Libs\Native", bsl + @"\Libs\Native");
}
else
{
Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\dc\Libs\Native", bsl + @"\Libs\Native");
}
}
}
}
}
if(dir.Name == "dep")
{
DirectoryInfo depdi = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"Files\dep\dep");
foreach (DirectoryInfo depdir in depdi.GetDirectories())
{
if (depdir.Name == "Plugins")
{
foreach (FileInfo file in depdir.GetFiles())
{
if (File.Exists(bsl + @"\Plugins\" + file.Name)) {
File.Delete(bsl + @"\Plugins\" + file.Name);
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
}
}
}
}
if (multiselected == "a")
{
if (dir.Name == "dovr")
{
DirectoryInfo dovrdi = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"Files\dovr");
foreach (DirectoryInfo dovrdir in dovrdi.GetDirectories())
{
if (dovrdir.Name == "Plugins")
{
foreach (FileInfo file in dovrdir.GetFiles())
{
if (File.Exists(bsl + @"\Plugins\" + file.Name))
{
File.Delete(bsl + @"\Plugins\" + file.Name);
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
}
}
if (dovrdir.Name == "Libs")
{
foreach (FileInfo file in dovrdir.GetFiles())
{
if (File.Exists(bsl + @"\Libs\" + file.Name))
{
File.Delete(bsl + @"\Libs\" + file.Name);
File.Move(file.FullName, bsl + @"\Libs\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Libs\" + file.Name);
}
}
}
}
}
}
if (dir.Name == "multiplayer")
{
DirectoryInfo multiplayerdi = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"Files\multiplayer");
foreach (DirectoryInfo multiplayerdir in multiplayerdi.GetDirectories())
{
if (multiplayerdir.Name == "Plugins")
{
foreach (FileInfo file in multiplayerdir.GetFiles())
{
if (File.Exists(bsl + @"\Plugins\" + file.Name)) {
File.Delete(bsl + @"\Plugins\" + file.Name);
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
}
}
if (multiplayerdir.Name == "Libs")
{
foreach (FileInfo file in multiplayerdir.GetFiles())
{
if (File.Exists(bsl + @"\Libs\" + file.Name)) {
File.Delete(bsl + @"\Libs\" + file.Name);
File.Move(file.FullName, bsl + @"\Libs\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Libs\" + file.Name);
}
}
}
}
}
}
if(multiselected == "a")
{
if (File.Exists(@"Files\CustomAvatar.dll"))
{
if (File.Exists(bsl + @"\Plugins\CustomAvatar.dll"))
{
File.Delete(bsl + @"\Plugins\CustomAvatar.dll");
File.Move(@"Files\CustomAvatar.dll", bsl + @"\Plugins\CustomAvatar.dll");
}
else
{
File.Move(@"Files\CustomAvatar.dll", bsl + @"\Plugins\CustomAvatar.dll");
}
}
}
statuslabel.Text = "Status: Complete!";
progressBar1.Value = 100;
allowinstalluninstall = true;
currentlyinstallinguninstalling = false;
button3.BackColor = SystemColors.MenuHighlight;
button4.BackColor = SystemColors.MenuHighlight;
DialogResult dialogResult = MessageBox.Show("Multiplayer is installed! Would you like to exit?", "Complete!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
Application.Exit();
}
}
19
View Source File : Form2.cs
License : MIT License
Project Creator : 200Tigersbloxed
License : MIT License
Project Creator : 200Tigersbloxed
void InstallMulti()
{
statuslabel.Text = "Status: Preparing";
progressBar1.Value = 10;
allowinstalluninstall = false;
currentlyinstallinguninstalling = true;
button3.BackColor = SystemColors.GrayText;
button4.BackColor = SystemColors.GrayText;
Directory.CreateDirectory("Files");
DirectoryInfo di = new DirectoryInfo("Files");
foreach (FileInfo file in di.GetFiles())
{
file.Delete();
}
foreach (DirectoryInfo dir in di.GetDirectories())
{
dir.Delete(true);
}
Directory.CreateDirectory(@"Files\multiplayer");
Directory.CreateDirectory(@"Files\dovr");
Directory.CreateDirectory(@"Files\ca");
Directory.CreateDirectory(@"Files\dc");
Directory.CreateDirectory(@"Files\dep");
statuslabel.Text = "Status: Downloading Multiplayer 1/6";
progressBar1.Value = 20;
using (var wc = new WebClient())
{
wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadCompleted);
wc.DownloadProgressChanged += wc_DownloadProgressChanged;
if(multiselected == "a") {
if(File.Exists(bsl + @"\Plugins\BeatSaberMultiplayerLite.dll"))
{
statuslabel.Text = "Status: Failed";
allowinstalluninstall = true;
currentlyinstallinguninstalling = false;
button3.BackColor = SystemColors.MenuHighlight;
button4.BackColor = SystemColors.MenuHighlight;
MessageBox.Show("Beat Saber Multiplayer Lite is installed! Installation Failed. Please Uninstall Zingabopp's Multiplayer Lite to continue installing Andruzzzhka's Multiplayer", "Uh Oh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
wc.DownloadFileAsync(new System.Uri("https://tigersserver.xyz/andruzzzhkalatest"), AppDomain.CurrentDomain.BaseDirectory + @"\Files\multiplayer.zip");
}
}
else if(multiselected == "z")
{
if (File.Exists(bsl + @"\Plugins\BeatSaberMultiplayer.dll"))
{
statuslabel.Text = "Status: Failed";
allowinstalluninstall = true;
currentlyinstallinguninstalling = false;
button3.BackColor = SystemColors.MenuHighlight;
button4.BackColor = SystemColors.MenuHighlight;
MessageBox.Show("Beat Saber Multiplayer is installed! Installation Failed. Please Uninstall Andruzzzhka's Multiplayer to continue installing Zingabopp's Multiplayer Lite", "Uh Oh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
wc.DownloadFileAsync(new System.Uri("https://tigersserver.xyz/zingabopplatest"), AppDomain.CurrentDomain.BaseDirectory + @"\Files\multiplayer.zip");
}
}
}
}
19
View Source File : SftpForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
private void ParseDireToQueue(string dir, DirectoryInfo dire)
{
FileInfo[] files = dire.GetFiles();
foreach (FileInfo file1 in files)
{
ParseFileToQueue(dir + dire.Name + "/", file1);
}
DirectoryInfo[] dires = dire.GetDirectories();
if (null != dires)
{
foreach (DirectoryInfo d in dires)
{
ParseDireToQueue(dir + dire.Name + "/", d);
}
}
}
19
View Source File : SftpWinForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
public void LoadDirFilesToListView(string path, LoadFilesResult result = null)
{
this.BeginInvoke((MethodInvoker)delegate()
{
try
{
DirectoryInfo dire = new DirectoryInfo(path);
if(dire.Exists){
listView1.Items.Clear();
LargeImages.Images.Clear();
SmallImages.Images.Clear();
FileInfo[] files = dire.GetFiles();
DirectoryInfo[] dires = dire.GetDirectories();
Icon icon = null;
ListViewItem item = null;
ListViewItem.ListViewSubItem subItem = null;
LargeImages.Images.Add(Properties.Resources.filen_64px);
LargeImages.Images.Add(Properties.Resources.folder_64px);
SmallImages.Images.Add(Properties.Resources.filen_16px);
SmallImages.Images.Add(Properties.Resources.folder_16px);
int index = 2;
item = new ListViewItem();
item.Text = "..";
subItem = new ListViewItem.ListViewSubItem();
subItem.Text = "";
item.SubItems.Add(subItem);
subItem = new ListViewItem.ListViewSubItem();
subItem.Text = "文件夹";
item.SubItems.Add(subItem);
subItem = new ListViewItem.ListViewSubItem();
subItem.Text = "";
item.SubItems.Add(subItem);
item.ImageIndex = 1;
listView1.Items.Add(item);
foreach (DirectoryInfo file in dires)
{
item = new ListViewItem();
item.Text = file.Name;
item.Tag = file;
subItem = new ListViewItem.ListViewSubItem();
subItem.Text = "";
item.SubItems.Add(subItem);
subItem = new ListViewItem.ListViewSubItem();
subItem.Text = "文件夹";
item.SubItems.Add(subItem);
subItem = new ListViewItem.ListViewSubItem();
subItem.Text = file.LastWriteTime.ToString("yyyy-MM-dd, HH:mm:ss");
item.SubItems.Add(subItem);
item.ImageIndex = 1;
listView1.Items.Add(item);
//Console.WriteLine(file.Name + " - " + file.ToString());
}
foreach(FileInfo file in files){
if(file.Extension == ".lnk"){
continue;
}
icon = Icon.ExtractreplacedociatedIcon(file.FullName);
LargeImages.Images.Add(icon.ToBitmap());
SmallImages.Images.Add(icon.ToBitmap());
item = new ListViewItem();
item.Text = file.Name;
item.Tag = file;
subItem = new ListViewItem.ListViewSubItem();
subItem.Text = Utils.getFileSize(file.Length);
item.SubItems.Add(subItem);
subItem = new ListViewItem.ListViewSubItem();
subItem.Text = file.Extension;
item.SubItems.Add(subItem);
subItem = new ListViewItem.ListViewSubItem();
subItem.Text = file.LastWriteTime.ToString("yyyy-MM-dd, HH:mm:ss");
item.SubItems.Add(subItem);
item.ImageIndex = index++;
listView1.Items.Add(item);
//Console.WriteLine(file.Name + " - " + file.ToString());
}
if (null != result)
{
result();
}
}
else
{
MessageBox.Show(this, "目录不存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception e)
{
logger.Error("加载数据失败:" + e.Message, e);
}
});
}
19
View Source File : DirectoryUtil.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public static bool SubDirectoryExist(DirectoryInfo directoryInfo)
{
if (!directoryInfo.Exists) return false;
return directoryInfo.GetDirectories() != null;
}
19
View Source File : DirectoryUtil.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public static DirectoryInfo[] GetDirectorys(DirectoryInfo directoryInfo, List<DirectoryInfo> directoryInfoList)
{
if (directoryInfo == null) return null;
if (SubDirectoryExist(directoryInfo))
{
directoryInfoList.AddRange(directoryInfo.GetDirectories());
}
foreach (DirectoryInfo item in directoryInfo.GetDirectories())
{
GetDirectorys(item, directoryInfoList);
}
return directoryInfoList.ToArray();
}
19
View Source File : FileUtil.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public static FileInfo[] GetFiles(DirectoryInfo directoryInfo, List<FileInfo> fileInfoList)
{
if (directoryInfo == null) return null;
if (FileExist(directoryInfo))
{
fileInfoList.AddRange(directoryInfo.GetFiles());
}
foreach (DirectoryInfo item in directoryInfo.GetDirectories())
{
GetFiles(item, fileInfoList);
}
return fileInfoList.ToArray();
}
19
View Source File : ToolsService.cs
License : Apache License 2.0
Project Creator : 91270
License : Apache License 2.0
Project Creator : 91270
private void GetFiles(string directory, List<string> list)
{
if (string.IsNullOrEmpty(directory)) return;
DirectoryInfo d = new DirectoryInfo(directory);
FileInfo[] files = d.GetFiles();
DirectoryInfo[] directs = d.GetDirectories();
foreach (FileInfo f in files)
{
list.Add(f.FullName);
}
//获取子文件夹内的文件列表,递归遍历
foreach (DirectoryInfo dd in directs)
{
GetFiles(dd.FullName, list);
}
}
19
View Source File : FileHelper.cs
License : GNU General Public License v3.0
Project Creator : 9vult
License : GNU General Public License v3.0
Project Creator : 9vult
public static DirectoryInfo[] GetDirs(DirectoryInfo parent)
{
return parent.GetDirectories();
}
19
View Source File : LootSwap.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
private static void ParseFolder(string folder, Dictionary<string, Dictionary<string, object>> files)
{
var di = new DirectoryInfo(folder);
if (!di.Exists)
{
Console.WriteLine($"{folder} not found");
return;
}
var _files = di.GetFiles();
foreach (var file in _files)
{
if (!file.Name.EndsWith(".cs"))
continue;
if (excludeList.Contains(file.Name))
continue;
var clreplacedName = file.Name.Replace(".cs", "");
var result = LootParser.ParseFile(file.FullName);
files.Add(clreplacedName, result);
}
var subfolders = di.GetDirectories();
foreach (var subfolder in subfolders)
ParseFolder(subfolder.FullName, files);
}
19
View Source File : IOUtil.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public static void CopyDirectory(string source, string target, CancellationToken cancellationToken)
{
// Validate args.
ArgUtil.Directory(source, nameof(source));
ArgUtil.NotNullOrEmpty(target, nameof(target));
ArgUtil.NotNull(cancellationToken, nameof(cancellationToken));
cancellationToken.ThrowIfCancellationRequested();
// Create the target directory.
Directory.CreateDirectory(target);
// Get the file contents of the directory to copy.
DirectoryInfo sourceDir = new DirectoryInfo(source);
foreach (FileInfo sourceFile in sourceDir.GetFiles() ?? new FileInfo[0])
{
// Check if the file already exists.
cancellationToken.ThrowIfCancellationRequested();
FileInfo targetFile = new FileInfo(Path.Combine(target, sourceFile.Name));
if (!targetFile.Exists ||
sourceFile.Length != targetFile.Length ||
sourceFile.LastWriteTime != targetFile.LastWriteTime)
{
// Copy the file.
sourceFile.CopyTo(targetFile.FullName, true);
}
}
// Copy the subdirectories.
foreach (DirectoryInfo subDir in sourceDir.GetDirectories() ?? new DirectoryInfo[0])
{
CopyDirectory(
source: subDir.FullName,
target: Path.Combine(target, subDir.Name),
cancellationToken: cancellationToken);
}
}
19
View Source File : FileSystem.cs
License : Apache License 2.0
Project Creator : adamralph
License : Apache License 2.0
Project Creator : adamralph
private static void DeleteDirectory(string path)
{
// Directory.Delete fails if anything in the tree has the read-only attribute set. ¯\_(ツ)_/¯
ResetAttributes(new DirectoryInfo(path));
static void ResetAttributes(DirectoryInfo directory)
{
foreach (var childDirectory in directory.GetDirectories())
{
ResetAttributes(childDirectory);
}
foreach (var file in directory.GetFiles())
{
file.Attributes = FileAttributes.Normal;
}
directory.Attributes = FileAttributes.Normal;
}
Directory.Delete(path, true);
if (!SpinWait.SpinUntil(() => !Directory.Exists(path), millisecondsTimeout))
{
throw new IOException($"Failed to delete directory '{path}'.");
}
}
19
View Source File : ClonesManager.cs
License : MIT License
Project Creator : adrenak
License : MIT License
Project Creator : adrenak
private static void CopyDirectoryWithProgressBarRecursive(DirectoryInfo source, DirectoryInfo destination,
ref long totalBytes, ref long copiedBytes, string progressBarPrefix = "")
{
/// Directory cannot be copied into itself.
if (source.FullName.ToLower() == destination.FullName.ToLower())
{
Debug.LogError("Cannot copy directory into itself.");
return;
}
/// Calculate total bytes, if required.
if (totalBytes == 0)
{
totalBytes = ClonesManager.GetDirectorySize(source, true, progressBarPrefix);
}
/// Create destination directory, if required.
if (!Directory.Exists(destination.FullName))
{
Directory.CreateDirectory(destination.FullName);
}
/// Copy all files from the source.
foreach (FileInfo file in source.GetFiles())
{
try
{
file.CopyTo(Path.Combine(destination.ToString(), file.Name), true);
}
catch (IOException)
{
/// Some files may throw IOException if they are currently open in Unity editor.
/// Just ignore them in such case.
}
/// Account the copied file size.
copiedBytes += file.Length;
/// Display the progress bar.
float progress = (float)copiedBytes / (float)totalBytes;
bool cancelCopy = EditorUtility.DisplayCancelableProgressBar(
progressBarPrefix + "Copying '" + source.FullName + "' to '" + destination.FullName + "'...",
"(" + (progress * 100f).ToString("F2") + "%) Copying file '" + file.Name + "'...",
progress);
if (cancelCopy) return;
}
/// Copy all nested directories from the source.
foreach (DirectoryInfo sourceNestedDir in source.GetDirectories())
{
DirectoryInfo nextDestingationNestedDir = destination.CreateSubdirectory(sourceNestedDir.Name);
ClonesManager.CopyDirectoryWithProgressBarRecursive(sourceNestedDir, nextDestingationNestedDir,
ref totalBytes, ref copiedBytes, progressBarPrefix);
}
}
19
View Source File : ClonesManager.cs
License : MIT License
Project Creator : adrenak
License : MIT License
Project Creator : adrenak
private static long GetDirectorySize(DirectoryInfo directory, bool includeNested = false,
string progressBarPrefix = "")
{
EditorUtility.DisplayProgressBar(progressBarPrefix + "Calculating size of directories...",
"Scanning '" + directory.FullName + "'...", 0f);
/// Calculate size of all files in directory.
long filesSize = directory.GetFiles().Sum((FileInfo file) => file.Length);
/// Calculate size of all nested directories.
long directoriesSize = 0;
if (includeNested)
{
IEnumerable<DirectoryInfo> nestedDirectories = directory.GetDirectories();
foreach (DirectoryInfo nestedDir in nestedDirectories)
{
directoriesSize += ClonesManager.GetDirectorySize(nestedDir, true, progressBarPrefix);
}
}
return filesSize + directoriesSize;
}
19
View Source File : ModEntry.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn
License : GNU General Public License v3.0
Project Creator : aedenthorn
public override void Entry(IModHelper helper)
{
context = this;
Config = Helper.ReadConfig<ModConfig>();
if (!Config.EnableMod)
return;
helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;
helper.Events.GameLoop.DayStarted += GameLoop_DayStarted;
helper.Events.Player.Warped += Player_Warped;
var harmony = HarmonyInstance.Create(ModManifest.UniqueID);
harmony.Patch(
original: AccessTools.Method(typeof(Object), nameof(Object.placementAction)),
postfix: new HarmonyMethod(typeof(ModEntry), nameof(placementAction_Postfix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Object), nameof(Object.performRemoveAction)),
postfix: new HarmonyMethod(typeof(ModEntry), nameof(performRemoveAction_Postfix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Object), nameof(Object.checkForAction)),
prefix: new HarmonyMethod(typeof(ModEntry), nameof(checkForAction_Prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Object), nameof(Object.isPreplacedable)),
prefix: new HarmonyMethod(typeof(ModEntry), nameof(Object_isPreplacedable_Prefix))
);
if (Config.LoadCustomTerrarium)
{
try
{
string path = Directory.GetParent(helper.DirectoryPath).GetDirectories().Where(f => f.FullName.EndsWith("[CP] Lively Frog Sanctuary")).FirstOrDefault()?.FullName;
if (path != null)
{
Texture2D tex = new Texture2D(Game1.graphics.GraphicsDevice, 48, 48);
Color[] data = new Color[tex.Width * tex.Height];
tex.GetData(data);
FileStream setStream = File.Open(Path.Combine(path, "replacedets", "frog-vivarium.png"), FileMode.Open);
Texture2D source = Texture2D.FromStream(Game1.graphics.GraphicsDevice, setStream);
setStream.Dispose();
Color[] srcData = new Color[source.Width * source.Height];
source.GetData(srcData);
for (int i = 0; i < srcData.Length; i++)
{
if (data.Length <= i + 48 * 12)
break;
data[i + 48 * 12] = srcData[i];
}
tex.SetData(data);
string outDir = Directory.GetParent(helper.DirectoryPath).GetDirectories().Where(f => f.FullName.EndsWith("[BC] Terrarium")).FirstOrDefault()?.FullName;
Stream stream = File.Create(Path.Combine(outDir, "replacedets", "terrarium.png"));
tex.SaveAsPng(stream, tex.Width, tex.Height);
stream.Dispose();
Monitor.Log("Terrarium overwritten with lively frog sanctuary", LogLevel.Debug);
}
}
catch (Exception ex)
{
Monitor.Log($"Can't load lively frog sanctuary for Terrarium\n{ex}", LogLevel.Error);
}
}
}
19
View Source File : FileExplorer.cs
License : MIT License
Project Creator : afxw
License : MIT License
Project Creator : afxw
public static FileSystemEntry[] GetDirectories(string path)
{
var info = new DirectoryInfo(path);
var dirs = new List<string>();
return info.GetDirectories().Select((dir) => new FileSystemEntry(dir.Name, dir.FullName, 0, FileType.Directory)).ToArray();
}
19
View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AhmedOS
License : GNU General Public License v3.0
Project Creator : AhmedOS
private void WalkDirectoryTree(System.IO.DirectoryInfo root, WebvttSubripConverter converter)
{
System.IO.FileInfo[] files = null;
System.IO.DirectoryInfo[] subDirs = null;
try
{
files = root.GetFiles("*.vtt");
}
catch (UnauthorizedAccessException e)
{
MessageBox.Show(Strings.unauthorizedAccess, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
catch (System.IO.DirectoryNotFoundException e)
{
MessageBox.Show(Strings.noOutputFolder, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (files != null)
{
foreach (System.IO.FileInfo fi in files)
{
logTextBox.Text += fi.FullName + Environment.NewLine;
try
{
converter.ConvertToSubrip(fi.FullName, root.FullName);
logTextBox.Text += Strings.convertedSuccessfully;
}
catch (Exception exception)
{
logTextBox.Text += "Error:: " + exception.Message;
}
logTextBox.Text += Environment.NewLine + Environment.NewLine;
}
subDirs = root.GetDirectories();
foreach (System.IO.DirectoryInfo dirInfo in subDirs)
{
WalkDirectoryTree(dirInfo, converter);
}
}
}
19
View Source File : BRPaths.cs
License : GNU General Public License v3.0
Project Creator : akaAgar
License : GNU General Public License v3.0
Project Creator : akaAgar
private static string FindRoot(string path = "", int loop = 0){
if(string.IsNullOrEmpty(path))
path = AppDomain.CurrentDomain.BaseDirectory;
path = Path.GetFullPath(path);
DirectoryInfo di = new DirectoryInfo(path);
var directories = di.GetDirectories();
if(directories.Any(x => x.Name == "Database"))
return Toolbox.NormalizeDirectoryPath(path);
if(loop > 10)
throw new Exception("Can't Find Database within 10 levels up on app");
return FindRoot(path + "/..", loop + 1);
}
19
View Source File : ContentsBrowser.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
public void Load(string path, bool forced = false)
{
if (!Folder && !forced) return;
if (Parent.Container != null)
{
Parent.Path = path;
int x;
Parent.Container.Disable();
var d = new DirectoryInfo(path); //replaceduming Test is your Folder
var files = d.GetFiles(); //Getting Text files
var dirs = d.GetDirectories();
x = files.Length + dirs.Length;
Parent.Items.Clear();
if (x == 0)
{
Parent.Container.Enable();
Parent.Container.UpdateFoldersTree();
return;
}
foreach (var dirr in dirs)
Task.Factory.StartNew(() =>
{
Dispatcher.BeginInvoke(DispatcherPriority.Input,
new Action(() =>
{
if (Parent.Path == Directory.GetParent(dirr.FullName).FullName)
Parent.AddFolder(dirr.Name, dirr.Extension, dirr.FullName);
if (x == Parent.Items.Count)
{
Parent.Container.Enable();
Parent.Container.UpdateFoldersTree();
}
}));
});
foreach (var file in files)
Task.Factory.StartNew(() =>
{
Dispatcher.BeginInvoke(DispatcherPriority.Input,
new Action(() =>
{
if (Parent.Path == Directory.GetParent(file.FullName).FullName)
Parent.AddFile(file.Name, file.Extension, file.FullName);
if (x == Parent.Items.Count)
{
Parent.Container.Enable();
Parent.Container.UpdateFoldersTree();
}
}));
});
}
}
19
View Source File : ContentsBrowser.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
private TreeViewItem CreateDirectoryNode(DirectoryInfo directoryInfo)
{
var directoryNode = new TreeViewItem {Header = new FolderItem(directoryInfo.FullName, directoryInfo.Name)};
Task.Factory.StartNew(() =>
{
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
{
try
{
foreach (var directory in directoryInfo.GetDirectories())
Task.Factory.StartNew(() =>
{
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(
() => { directoryNode.Items.Add(CreateDirectoryNode(directory)); }));
});
}
catch
{
}
}));
});
return directoryNode;
}
19
View Source File : BuildPostProcessor.cs
License : MIT License
Project Creator : aleab
License : MIT License
Project Creator : aleab
[PostProcessBuild(1)]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
{
// Only Windows x86 and x86_64 atm.
if (target != BuildTarget.StandaloneWindows && target != BuildTarget.StandaloneWindows64)
return;
////////////////////////////////////////////////////////////////
// COPY EVERY FILE IN THE PLUGIN DIRECTORY TO THE BUILD PATH. //
////////////////////////////////////////////////////////////////
// Get the source directory (replacedets/Plugins or replacedets/Plugins/x86 or replacedets/Plugins/x86_64).
string srcPluginsFolder = string.Format("{0}/{1}", Application.dataPath, "Plugins");
switch (target)
{
case BuildTarget.StandaloneWindows:
if (Directory.Exists(srcPluginsFolder + "/x86"))
srcPluginsFolder += "/x86";
break;
case BuildTarget.StandaloneWindows64:
if (Directory.Exists(srcPluginsFolder + "/x86_64"))
srcPluginsFolder += "/x86_64";
break;
default:
break;
}
// Get the destination directory (<BUILT_EXE_PATH>/<EXE_NAME>_Data/Plugins).
int splitIndex = pathToBuiltProject.LastIndexOf('/');
string buildPath = pathToBuiltProject.Substring(0, splitIndex);
string executableName = pathToBuiltProject.Substring(splitIndex + 1);
string buildPluginsPath = string.Format("{0}/{1}_Data/Plugins", buildPath, Path.GetFileNameWithoutExtension(executableName));
DirectoryInfo srcPluginsFolderInfo = new DirectoryInfo(srcPluginsFolder);
DirectoryInfo buildPluginsPathInfo = new DirectoryInfo(buildPluginsPath);
// Exclude some files (.dlls should already be there!)
var srcPluginsFolderFiles = srcPluginsFolderInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly)
.Where(fi => !fi.Name.EndsWith(".meta") && !fi.Name.EndsWith(".dll") &&
!fi.Name.EndsWith(".pdb") && !fi.Name.EndsWith(".lib") &&
!fi.Name.EndsWith(".mdb") && !fi.Name.EndsWith(".xml"));
var srcPluginsFolderDirectories = srcPluginsFolderInfo.GetDirectories();
// Copy selected files and sub-directories.
foreach (var dir in srcPluginsFolderDirectories)
DirectoryCopy(dir.FullName, string.Format("{0}/{1}", buildPluginsPathInfo.FullName, dir.Name), true);
foreach (var file in srcPluginsFolderFiles)
File.Copy(file.FullName, string.Format("{0}/{1}", buildPluginsPathInfo.FullName, file.Name), false);
}
19
View Source File : BuildPostProcessor.cs
License : MIT License
Project Creator : aleab
License : MIT License
Project Creator : aleab
private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
{
// Get the subdirectories for the specified directory.
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
if (!dir.Exists)
throw new DirectoryNotFoundException("Source directory does not exist or could not be found: " + sourceDirName);
DirectoryInfo[] dirs = dir.GetDirectories();
// If the destination directory doesn't exist, create it.
if (!Directory.Exists(destDirName))
Directory.CreateDirectory(destDirName);
// Get the files in the directory and copy them to the new location.
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
string temppath = Path.Combine(destDirName, file.Name);
file.CopyTo(temppath, false);
}
// If copying subdirectories, copy them and their contents to new location.
if (copySubDirs)
{
foreach (DirectoryInfo subdir in dirs)
{
string temppath = Path.Combine(destDirName, subdir.Name);
DirectoryCopy(subdir.FullName, temppath, copySubDirs);
}
}
}
19
View Source File : DirectoryOptions.cs
License : MIT License
Project Creator : AlexanderFroemmgen
License : MIT License
Project Creator : AlexanderFroemmgen
public void CopyDirectoryRecursively(DirectoryInfo fromDi, string destPath)
{
new DirectoryInfo(destPath).Create();
foreach (var dirEntry in fromDi.GetDirectories())
{
var tmpDestPath = destPath + "/" + dirEntry.Name;
new DirectoryInfo(tmpDestPath).Create();
CopyDirectoryRecursively(dirEntry, tmpDestPath);
}
foreach (var dirEntry in fromDi.GetFiles())
{
dirEntry.CopyTo(destPath + "/" + dirEntry.Name);
}
}
19
View Source File : DirectoryOptions.cs
License : MIT License
Project Creator : AlexanderFroemmgen
License : MIT License
Project Creator : AlexanderFroemmgen
private void GetAllFilesRecursively(DirectoryInfo di, List<string> result, string prefix = "")
{
foreach (var dirEntry in di.GetFiles())
{
result.Add(prefix + dirEntry.Name);
}
foreach (var dirEntry in di.GetDirectories())
{
GetAllFilesRecursively(dirEntry, result, prefix + dirEntry.Name + "/");
}
}
19
View Source File : BuildProcessCallbacksHandler.cs
License : Apache License 2.0
Project Creator : Algoryx
License : Apache License 2.0
Project Creator : Algoryx
public static void CopyDirectory( DirectoryInfo source, DirectoryInfo destination )
{
if ( !destination.Exists )
destination.Create();
foreach ( var fileInfo in source.GetFiles() )
fileInfo.CopyTo( Path.Combine( destination.FullName, fileInfo.Name ), true );
foreach ( var directoryInfo in source.GetDirectories() )
CopyDirectory( directoryInfo, new DirectoryInfo( Path.Combine( destination.FullName, directoryInfo.Name ) ) );
}
19
View Source File : DirectoryContentHandler.cs
License : Apache License 2.0
Project Creator : Algoryx
License : Apache License 2.0
Project Creator : Algoryx
private void CollectData( DirectoryInfo currentDirectory )
{
try {
var files = currentDirectory.GetFiles( "*.*" );
foreach ( var file in files ) {
if ( MayDelete( file ) )
m_files.Add( file );
else
AddIgnoredFile( file );
}
foreach ( var directory in currentDirectory.GetDirectories() ) {
m_directories.Add( directory );
CollectData( directory );
}
}
catch ( System.UnauthorizedAccessException ) {
}
catch ( DirectoryNotFoundException ) {
}
catch ( System.Exception e ) {
Debug.LogException( e );
}
}
19
View Source File : PathExtensions.cs
License : MIT License
Project Creator : aliakseiherman
License : MIT License
Project Creator : aliakseiherman
public static void Empty(this DirectoryInfo directory)
{
foreach (FileInfo file in directory.GetFiles()) file.Delete();
foreach (DirectoryInfo subDirectory in directory.GetDirectories()) subDirectory.Delete(true);
}
19
View Source File : PythonScript.cs
License : MIT License
Project Creator : allisterb
License : MIT License
Project Creator : allisterb
protected void SetBinDir()
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT && !VirtualEnvActivated && VirtualEnvDir != null && VirtualEnvDir.GetDirectories().Any(d => d.Name.ToLower() == "scripts"))
{
binDir = VirtualEnvDir.GetDirectories().First(d => d.Name.ToLower() == "scripts").FullName;
}
}
19
View Source File : PythonScript.cs
License : MIT License
Project Creator : allisterb
License : MIT License
Project Creator : allisterb
protected void SetPythonPath()
{
string ppath = Environment.GetEnvironmentVariable("PYTHONPATH");
if (Environment.OSVersion.Platform == PlatformID.Win32NT && VirtualEnvDir != null && ppath.IsEmpty() && VirtualEnvDir.GetDirectories().Any(d => d.Name.ToLower() == "lib"))
{
DirectoryInfo lib = VirtualEnvDir.GetDirectories().First(d => d.Name.ToLower() == "lib");
if (lib.GetDirectories().Any(d => d.Name.ToLower() == "site-packages"))
{
string site_packages = lib.GetDirectories().First(d => d.Name.ToLower() == "site-packages").FullName;
Info("Incuding virtual environment user modules directory {0}.", site_packages);
PythonEngine.PythonPath += ";{0}".F(site_packages);
}
}
else if (Environment.OSVersion.Platform == PlatformID.Unix && !VirtualEnvActivated && VirtualEnvDir != null && ppath.IsEmpty() && VirtualEnvDir.GetDirectories().Any(d => d.Name.ToLower() == "lib"))
{
DirectoryInfo lib = VirtualEnvDir.GetDirectories().First(d => d.Name.ToLower() == "lib");
if (lib.GetDirectories().Any(d => d.Name.ToLower() == "python3.6"))
{
DirectoryInfo python36 = lib.GetDirectories().First(d => d.Name.ToLower() == "python3.6");
if (python36.GetDirectories().Any(d => d.Name.ToLower() == "site-packages"))
{
string site_packages = python36.GetDirectories().First(d => d.Name.ToLower() == "site-packages").FullName;
Info("Incuding virtual environment user modules directory {0}.", site_packages);
PythonEngine.PythonPath += ";{0}".F(site_packages);
}
}
}
/*
IntPtr path = PySys_GetObject("path");
IntPtr item = PyString_FromString(rtdir);
PyList_Append(path, item);
XDecref(item);
*/
Info("Python user module paths are: {0}.", PythonEngine.PythonPath);
}
19
View Source File : FileSystemResultsWriter.cs
License : Apache License 2.0
Project Creator : allure-framework
License : Apache License 2.0
Project Creator : allure-framework
public void CleanUp()
{
using (var mutex = new Mutex(false, "729dc988-0e9c-49d0-9e50-17e0df3cd82b"))
{
mutex.WaitOne();
var directory = new DirectoryInfo(outputDirectory);
foreach (var file in directory.GetFiles()) file.Delete();
foreach (var dir in directory.GetDirectories()) dir.Delete(true);
mutex.ReleaseMutex();
}
}
19
View Source File : GuidObjectFolder.cs
License : MIT License
Project Creator : Alprog
License : MIT License
Project Creator : Alprog
private void LoadFromFolder(string folderPath)
{
var dirInfo = new DirectoryInfo(folderPath);
var items = new List<GuidObject>();
var settings = Serializer.Instance.State.Settings;
var files = dirInfo.GetFiles("*.sav");
foreach (var fileInfo in files)
{
var path = Utils.PathCombine(folderPath, fileInfo.Name);
var bytes = FileSystemCache.ReadAllBytes(path);
var item = Serializer.Instance.Deserialize<GuidObject>(bytes, settings);
item.SetParentFolder(this);
lock (items)
{
items.Add(item);
}
}
JoinItems(items);
foreach (var subDirInfo in dirInfo.GetDirectories())
{
var subFolder = new Folder(subDirInfo.Name, this);
subFolder.LoadFromFolder(Utils.PathCombine(folderPath, subDirInfo.Name));
SubFolders[subDirInfo.Name] = subFolder;
}
}
19
View Source File : ResourceLoader.cs
License : MIT License
Project Creator : AlternateLife
License : MIT License
Project Creator : AlternateLife
private IEnumerable<ResourceHandler> FindResources()
{
var directoryFolder = new DirectoryInfo(_basePath);
foreach (var directory in directoryFolder.GetDirectories())
{
yield return new ResourceHandler(_plugin, directory, this);
}
}
19
View Source File : GitRepository.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
private static void CopyAll(string sourceDirectory, string targetDirectory)
{
DirectoryInfo source = new DirectoryInfo(sourceDirectory);
DirectoryInfo target = new DirectoryInfo(targetDirectory);
foreach (FileInfo file in source.GetFiles())
{
File.SetAttributes(file.FullName, FileAttributes.Normal);
file.CopyTo(Path.Combine(target.FullName, file.Name), true);
}
foreach (DirectoryInfo subDirectiory in source.GetDirectories())
{
DirectoryInfo nextTargetSubDir =
target.CreateSubdirectory(subDirectiory.Name);
CopyAll(subDirectiory.FullName, nextTargetSubDir.FullName);
}
}
19
View Source File : DirectoryHelper.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
public static void DeleteFilesAndDirectory(string directoryToDelete)
{
DirectoryInfo directoryToDeleteInfo = new DirectoryInfo(directoryToDelete);
if (!directoryToDeleteInfo.Exists)
{
return;
}
DirectoryInfo[] subDirectories = directoryToDeleteInfo.GetDirectories();
FileInfo[] files = directoryToDeleteInfo.GetFiles();
foreach (FileInfo file in files)
{
File.SetAttributes(file.FullName, FileAttributes.Normal);
File.Delete(file.FullName);
}
foreach (DirectoryInfo directory in subDirectories)
{
DeleteFilesAndDirectory(directory.FullName);
}
File.SetAttributes(directoryToDeleteInfo.FullName, FileAttributes.Normal);
Directory.Delete(directoryToDeleteInfo.FullName);
}
19
View Source File : TestDataHelper.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
public static void DeleteDirectory(string directoryToDelete, bool deleteSubDirs = true)
{
DirectoryInfo directoryToDeleteInfo = new DirectoryInfo(directoryToDelete);
if (!directoryToDeleteInfo.Exists)
{
throw new DirectoryNotFoundException($"Directory does not exist or could not be found: {directoryToDelete}");
}
DirectoryInfo[] subDirectories = directoryToDeleteInfo.GetDirectories();
FileInfo[] files = directoryToDeleteInfo.GetFiles();
foreach (FileInfo file in files)
{
File.Delete(file.FullName);
}
if (deleteSubDirs)
{
foreach (DirectoryInfo directory in subDirectories)
{
DeleteDirectory(directory.FullName);
}
}
Directory.Delete(directoryToDeleteInfo.FullName);
}
19
View Source File : TestDataHelper.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
public async static Task CopyDirectory(string sourceDirectory, string targetDirectory, bool copySubDirs = true)
{
DirectoryInfo sourceDirectoryInfo = new DirectoryInfo(sourceDirectory);
if (!sourceDirectoryInfo.Exists)
{
throw new DirectoryNotFoundException($"Source directory does not exist or could not be found: {sourceDirectory}");
}
DirectoryInfo[] sourceSubDirectories = sourceDirectoryInfo.GetDirectories();
Directory.CreateDirectory(targetDirectory);
FileInfo[] files = sourceDirectoryInfo.GetFiles();
foreach (FileInfo file in files)
{
string tempPath = Path.Combine(targetDirectory, file.Name);
var sourceBytes = ReadAllBytesWithoutLocking(file.FullName);
await File.WriteAllBytesAsync(tempPath, sourceBytes);
File.SetAttributes(tempPath, FileAttributes.Normal);
}
if (copySubDirs)
{
foreach (DirectoryInfo subdir in sourceSubDirectories)
{
string tempPath = Path.Combine(targetDirectory, subdir.Name);
await CopyDirectory(subdir.FullName, tempPath, copySubDirs);
}
}
}
19
View Source File : HelperMethods.cs
License : GNU General Public License v3.0
Project Creator : AM2R-Community-Developers
License : GNU General Public License v3.0
Project Creator : AM2R-Community-Developers
public static void DirectoryCopy(string sourceDirName, string destDirName, bool overwriteFiles = true, bool copySubDirs = true)
{
// Get the subdirectories for the specified directory.
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
if (!dir.Exists)
{
throw new DirectoryNotFoundException(
"Source directory does not exist or could not be found: "
+ sourceDirName);
}
DirectoryInfo[] dirs = dir.GetDirectories();
// If the destination directory doesn't exist, create it.
Directory.CreateDirectory(destDirName);
// Get the files in the directory and copy them to the new location.
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
string tempPath = Path.Combine(destDirName, file.Name);
file.CopyTo(tempPath, overwriteFiles);
}
// If copying subdirectories, copy them and their contents to new location.
if (copySubDirs)
{
foreach (DirectoryInfo subdir in dirs)
{
string tempPath = Path.Combine(destDirName, subdir.Name);
DirectoryCopy(subdir.FullName, tempPath, overwriteFiles, copySubDirs);
}
}
}
19
View Source File : LauncherUpdater.cs
License : GNU General Public License v3.0
Project Creator : AM2R-Community-Developers
License : GNU General Public License v3.0
Project Creator : AM2R-Community-Developers
public static void Main()
{
log.Info("Running update check...");
string version = VERSION.Replace(".", "");
//update section
//delete old files that have been left
if (File.Exists(CrossPlatformOperations.CURRENTPATH + "/AM2RLauncher.bak"))
{
log.Info("AM2RLauncher.bak detected. Removing file.");
File.Delete(CrossPlatformOperations.CURRENTPATH + "/AM2RLauncher.bak");
}
if (currentPlatform.IsWinForms && File.Exists(oldConfigPath))
{
log.Info(CrossPlatformOperations.LAUNCHERNAME + ".oldCfg detected. Removing file.");
File.Delete(oldConfigPath);
}
if (currentPlatform.IsWinForms && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/oldLib"))
{
log.Info("Old lib folder detected, removing folder.");
Directory.Delete(CrossPlatformOperations.CURRENTPATH + "/oldLib", true);
}
// Clean up old update libs
if (currentPlatform.IsWinForms && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/lib"))
{
foreach (FileInfo file in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetFiles())
{
if (file.Name.EndsWith(".bak"))
file.Delete();
}
// Do the same for each subdir
foreach (DirectoryInfo dir in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetDirectories())
{
foreach (FileInfo file in dir.GetFiles())
{
if (file.Name.EndsWith(".bak"))
file.Delete();
}
}
}
//check settings if autoUpdateLauncher is set to true
bool autoUpdate = bool.Parse(CrossPlatformOperations.ReadFromConfig("AutoUpdateLauncher"));
if (autoUpdate)
{
log.Info("AutoUpdate Launcher set to true!");
//this is supposed to fix the updater throwing an exception on windows 7 and earlier(?)
//see this for information: https://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel and https://stackoverflow.com/a/50977774
if (currentPlatform.IsWinForms)
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest");
HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException)
{
log.Error("WebException caught! Displaying MessageBox.");
MessageBox.Show(Language.Text.NoInternetConnection);
return;
}
Uri realUri = response.ResponseUri;
string onlineVersion = realUri.AbsoluteUri.Substring(realUri.AbsoluteUri.LastIndexOf('/') + 1);
bool isCurrentVersionOutdated = false;
string[] localVersionArray = VERSION.Split('.');
string[] onlineVersionArray = onlineVersion.Split('.');
for (int i = 0; i < localVersionArray.Length; i++)
{
if (int.Parse(onlineVersionArray[i]) > int.Parse(localVersionArray[i]))
{
isCurrentVersionOutdated = true;
break;
}
}
if (isCurrentVersionOutdated)
{
log.Info("Current version (" + VERSION + ") is outdated! Initiating update for version " + onlineVersion + ".");
string tmpUpdatePath = CrossPlatformOperations.CURRENTPATH + "/tmpupdate/";
string zipPath = CrossPlatformOperations.CURRENTPATH + "/launcher.zip";
// Clean tmpupdate
if (Directory.Exists(tmpUpdatePath))
Directory.Delete(tmpUpdatePath);
if (!Directory.Exists(tmpUpdatePath))
Directory.CreateDirectory(tmpUpdatePath);
try
{
using (var client = new WebClient())
{
string platformSuffix = "";
if (currentPlatform.IsWinForms) platformSuffix = "_win";
else if (currentPlatform.IsGtk) platformSuffix = "_lin";
log.Info("Downloading https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_" + onlineVersion + platformSuffix + ".zip to " + zipPath + ".");
client.DownloadFile("https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_" + onlineVersion + platformSuffix + ".zip", zipPath);
log.Info("File successfully downloaded.");
}
}
catch(UnauthorizedAccessException)
{
log.Error("UnauthorizedAccessException caught! Displaying MessageBox.");
MessageBox.Show(Language.Text.UnauthorizedAccessMessage);
return;
}
ZipFile.ExtractToDirectory(zipPath, tmpUpdatePath);
log.Info("Updates successfully extracted to " + tmpUpdatePath);
File.Delete(zipPath);
File.Move(updatePath + "/" + CrossPlatformOperations.LAUNCHERNAME, CrossPlatformOperations.CURRENTPATH + "/AM2RLauncher.bak");
if (currentPlatform.IsWinForms) File.Move(CrossPlatformOperations.LAUNCHERNAME + ".config", CrossPlatformOperations.LAUNCHERNAME + ".oldCfg");
foreach (var file in new DirectoryInfo(tmpUpdatePath).GetFiles())
{
log.Info("Moving " + file.FullName + " to " + CrossPlatformOperations.CURRENTPATH + "/" + file.Name);
File.Copy(file.FullName, updatePath + "/" + file.Name, true);
}
// for windows, the actual application is in "AM2RLauncher.dll". Which means, we need to update the lib folder as well.
if (currentPlatform.IsWinForms && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/lib"))
{
// Directory.Move(CrossPlatformOperations.CURRENTPATH + "/lib", CrossPlatformOperations.CURRENTPATH + "/oldLib");
// So, because Windows behavior is dumb...
// Rename all files in lib to *.bak
foreach (FileInfo file in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetFiles())
{
file.CopyTo(file.Directory + file.Name + ".bak");
}
// Do the same for each subdir
foreach(DirectoryInfo dir in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetDirectories())
{
foreach (FileInfo file in dir.GetFiles())
{
file.CopyTo(file.Directory + file.Name + ".bak");
}
}
// Yes, the above calls could be recursive. No, I can't be bothered to make them as such.
HelperMethods.DirectoryCopy(tmpUpdatePath + "lib", CrossPlatformOperations.CURRENTPATH + "/lib", true);
}
Directory.Delete(tmpUpdatePath, true);
CrossPlatformOperations.CopyOldConfigToNewConfig();
log.Info("Files extracted. Preparing to restart executable...");
if (currentPlatform.IsGtk) System.Diagnostics.Process.Start("chmod", "+x ./AM2RLauncher.Gtk");
System.Diagnostics.Process.Start(updatePath + "/" + CrossPlatformOperations.LAUNCHERNAME);
Environment.Exit(0);
}
}
else
{
log.Info("AutoUpdate Launcher set to false. Exiting update check.");
}
}
19
View Source File : ModPacker.cs
License : GNU General Public License v3.0
Project Creator : AM2R-Community-Developers
License : GNU General Public License v3.0
Project Creator : AM2R-Community-Developers
private void CreateModPack(string operatingSystem, string input, string output)
{
LoadProfileParameters(operatingSystem);
// Cleanup in case of previous errors
if (Directory.Exists(Path.GetTempPath() + "\\AM2RModPacker"))
{
Directory.Delete(Path.GetTempPath() + "\\AM2RModPacker", true);
}
// Create temp work folders
string tempPath = "",
tempOriginalPath = "",
tempModPath = "",
tempProfilePath = "";
// We might not have permission to access to the temp directory, so we need to catch the exception.
try
{
tempPath = Directory.CreateDirectory(Path.GetTempPath() + "\\AM2RModPacker").FullName;
tempOriginalPath = Directory.CreateDirectory(tempPath + "\\original").FullName;
tempModPath = Directory.CreateDirectory(tempPath + "\\mod").FullName;
tempProfilePath = Directory.CreateDirectory(tempPath + "\\profile").FullName;
}
catch (System.Security.SecurityException)
{
MessageBox.Show("Could not create temp directory! Please run the application with administrator rights.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
AbortPatch();
return;
}
// Extract 1.1 and modded AM2R to their own directories in temp work
ZipFile.ExtractToDirectory(originalPath, tempOriginalPath);
ZipFile.ExtractToDirectory(input, tempModPath);
if (Directory.Exists(tempModPath + "\\AM2R"))
tempModPath += "\\AM2R";
// Verify 1.1 with an MD5. If it does not match, exit cleanly and provide a warning window.
try
{
string newMD5 = CalculateMD5(tempOriginalPath + "\\data.win");
if (newMD5 != ORIGINAL_MD5)
{
// Show error box
MessageBox.Show("1.1 data.win does not meet MD5 checksum! Mod packaging aborted.\n1.1 MD5: " + ORIGINAL_MD5 + "\nYour MD5: " + newMD5, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
AbortPatch();
return;
}
}
catch (FileNotFoundException)
{
// Show error message
MessageBox.Show("data.win not found! Are you sure you selected AM2R 1.1? Mod packaging aborted.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
AbortPatch();
return;
}
// Create AM2R.exe and data.win patches
if (profile.OperatingSystem == "Windows")
{
if (!File.Exists(tempModPath + "/AM2R.exe"))
{
var result = MessageBox.Show("Modded game not found, make sure it's not placed in any subfolders.\nCreated profile will likely not be installable, are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result != DialogResult.Yes)
AbortPatch();
}
if (File.Exists(tempModPath + "profile.xml"))
{
var result = MessageBox.Show("profile.xml found. This file is used by the AM2RLauncher to determine profile stats and its inclusion may make the profile uninstallable. Are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result != DialogResult.Yes)
AbortPatch();
}
if (profile.UsesYYC)
{
CreatePatch(tempOriginalPath + "\\data.win", tempModPath + "\\AM2R.exe", tempProfilePath + "\\AM2R.xdelta");
}
else
{
CreatePatch(tempOriginalPath + "\\data.win", tempModPath + "\\data.win", tempProfilePath + "\\data.xdelta");
CreatePatch(tempOriginalPath + "\\AM2R.exe", tempModPath + "\\AM2R.exe", tempProfilePath + "\\AM2R.xdelta");
}
}
else if (profile.OperatingSystem == "Linux")
{
string runnerName = File.Exists(tempModPath + "\\" + "AM2R") ? "AM2R" : "runner";
if (!File.Exists(tempModPath + "/" + runnerName))
{
var result = MessageBox.Show("Modded Linux game not found, make sure it's not placed in any subfolders.\nCreated profile will likely not be installable, are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result != DialogResult.Yes)
AbortPatch();
}
if (File.Exists(tempModPath + "profile.xml"))
{
var result = MessageBox.Show("profile.xml found. This file is used by the AM2RLauncher to determine profile stats and its inclusion may make the profile uninstallable. Are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result != DialogResult.Yes)
AbortPatch();
}
CreatePatch(tempOriginalPath + "\\data.win", tempModPath + "\\replacedets\\game.unx", tempProfilePath + "\\game.xdelta");
CreatePatch(tempOriginalPath + "\\AM2R.exe", tempModPath + "\\" + runnerName, tempProfilePath + "\\AM2R.xdelta");
}
// Create game.droid patch and wrapper if Android is supported
if (profile.Android)
{
string tempAndroid = Directory.CreateDirectory(tempPath + "\\android").FullName;
// Extract APK
// - java -jar apktool.jar d "%~dp0AM2RWrapper_old.apk"
// Process startInfo
ProcessStartInfo procStartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
WorkingDirectory = tempAndroid,
Arguments = "/C java -jar \"" + localPath + "\\utilities\\android\\apktool.jar\" d -f -o \"" + tempAndroid + "\" \"" + apkPath + "\"",
UseShellExecute = false,
CreateNoWindow = true
};
// Run process
using (Process proc = new Process { StartInfo = procStartInfo })
{
proc.Start();
proc.WaitForExit();
}
// Create game.droid patch
CreatePatch(tempOriginalPath + "\\data.win", tempAndroid + "\\replacedets\\game.droid", tempProfilePath + "\\droid.xdelta");
// Delete excess files in APK
// Create whitelist
string[] whitelist = { "splash.png", "portrait_splash.png" };
// Get directory
DirectoryInfo androidreplacedets = new DirectoryInfo(tempAndroid + "\\replacedets");
// Delete files
foreach (FileInfo file in androidreplacedets.GetFiles())
{
if (file.Name.EndsWith(".ini") && file.Name != "modifiers.ini")
{
if (File.Exists(tempProfilePath + "\\AM2R.ini"))
{
// This shouldn't be a problem... normally...
File.Delete(tempProfilePath + "\\AM2R.ini");
}
File.Copy(file.FullName, tempProfilePath + "\\AM2R.ini");
}
if (!whitelist.Contains(file.Name))
{
File.Delete(file.FullName);
}
}
foreach (DirectoryInfo dir in androidreplacedets.GetDirectories())
{
Directory.Delete(dir.FullName, true);
}
// Create wrapper
// Process startInfo
// - java -jar apktool.jar b "%~dp0AM2RWrapper_old" -o "%~dp0AM2RWrapper.apk"
ProcessStartInfo procStartInfo2 = new ProcessStartInfo
{
FileName = "cmd.exe",
WorkingDirectory = tempAndroid,
Arguments = "/C java -jar \"" + localPath + "\\utilities\\android\\apktool.jar\" b -f \"" + tempAndroid + "\" -o \"" + tempProfilePath + "\\AM2RWrapper.apk\"",
UseShellExecute = false,
CreateNoWindow = true
};
// Run process
using (Process proc = new Process { StartInfo = procStartInfo2 })
{
proc.Start();
proc.WaitForExit();
}
string tempAndroidProfilePath = tempProfilePath + "\\android";
Directory.CreateDirectory(tempAndroidProfilePath);
File.Move(tempProfilePath + "\\AM2RWrapper.apk", tempAndroidProfilePath + "\\AM2RWrapper.apk");
if (File.Exists(tempProfilePath + "\\AM2R.ini"))
File.Move(tempProfilePath + "\\AM2R.ini", tempAndroidProfilePath + "\\AM2R.ini");
}
// Copy datafiles (exclude .ogg if custom music is not selected)
DirectoryInfo dinfo = new DirectoryInfo(tempModPath);
if (profile.OperatingSystem == "Linux")
dinfo = new DirectoryInfo(tempModPath + "\\replacedets");
Directory.CreateDirectory(tempProfilePath + "\\files_to_copy");
if (profile.UsesCustomMusic)
{
// Copy files, excluding the blacklist
CopyFilesRecursive(dinfo, DATAFILES_BLACKLIST, tempProfilePath + "\\files_to_copy");
}
else
{
// Get list of 1.1's music files
string[] musFiles = Directory.GetFiles(tempOriginalPath, "*.ogg").Select(file => Path.GetFileName(file)).ToArray();
if (profile.OperatingSystem == "Linux")
musFiles = Directory.GetFiles(tempOriginalPath, "*.ogg").Select(file => Path.GetFileName(file).ToLower()).ToArray();
// Combine musFiles with the known datafiles for a blacklist
string[] blacklist = musFiles.Concat(DATAFILES_BLACKLIST).ToArray();
// Copy files, excluding the blacklist
CopyFilesRecursive(dinfo, blacklist, tempProfilePath + "\\files_to_copy");
}
// Export profile as XML
string xmlOutput = Serializer.Serialize<ModProfileXML>(profile);
File.WriteAllText(tempProfilePath + "\\profile.xml", xmlOutput);
// Compress temp folder to .zip
if (File.Exists(output))
{
File.Delete(output);
}
ZipFile.CreateFromDirectory(tempProfilePath, output);
// Delete temp folder
Directory.Delete(tempPath, true);
}
19
View Source File : ModDownloader.cs
License : GNU General Public License v3.0
Project Creator : amakvana
License : GNU General Public License v3.0
Project Creator : amakvana
private void DeleteModData(string path)
{
DirectoryInfo dir = new DirectoryInfo(path);
foreach (FileInfo fi in dir.GetFiles())
{
fi.Delete();
}
foreach (DirectoryInfo di in dir.GetDirectories())
{
DeleteModData(di.FullName);
di.Delete();
}
}
19
View Source File : ModeHelper.cs
License : MIT License
Project Creator : AmazingDM
License : MIT License
Project Creator : AmazingDM
public static void Load()
{
Global.Modes.Clear();
if (!Directory.Exists(MODE_DIR)) return;
var stack = new Stack<string>();
stack.Push(MODE_DIR);
while (stack.Count > 0)
{
var dirInfo = new DirectoryInfo(stack.Pop());
try
{
foreach (var childDirInfo in dirInfo.GetDirectories())
stack.Push(childDirInfo.FullName);
foreach (var childFileInfo in dirInfo.GetFiles().Where(info => info.Name.EndsWith(".txt")))
LoadModeFile(childFileInfo.FullName);
}
catch
{
// ignored
}
}
Sort();
}
19
View Source File : Netch.cs
License : MIT License
Project Creator : AmazingDM
License : MIT License
Project Creator : AmazingDM
[STAThread]
public static void Main(string[] args)
{
if (args.Contains("-console"))
{
if (!NativeMethods.AttachConsole(-1))
{
NativeMethods.AllocConsole();
}
}
// 创建互斥体防止多次运行
using (var mutex = new Mutex(false, "Global\\Netch"))
{
// 设置当前目录
Directory.SetCurrentDirectory(Global.NetchDir);
Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process) + ";" + Path.Combine(Global.NetchDir, "bin"), EnvironmentVariableTarget.Process);
// 预创建目录
var directories = new[] {"mode", "data", "i18n", "logging"};
foreach (var item in directories)
{
if (!Directory.Exists(item))
{
Directory.CreateDirectory(item);
}
}
// 加载配置
Configuration.Load();
// 加载语言
i18N.Load(Global.Settings.Language);
// 检查是否已经运行
/*if (!mutex.WaitOne(0, false))
{
OnlyInstance.Send(OnlyInstance.Commands.Show);
Logging.Info("唤起单实例");
// 退出进程
Environment.Exit(1);
}*/
// 清理上一次的日志文件,防止淤积占用磁盘空间
if (Directory.Exists("logging"))
{
var directory = new DirectoryInfo("logging");
foreach (var file in directory.GetFiles())
{
file.Delete();
}
foreach (var dir in directory.GetDirectories())
{
dir.Delete(true);
}
}
Logging.Info($"版本: {UpdateChecker.Owner}/{UpdateChecker.Repo}@{UpdateChecker.Version}");
Task.Run(() =>
{
Logging.Info($"主程序 SHA256: {Utils.Utils.SHA256CheckSum(Application.ExecutablePath)}");
});
Task.Run(() =>
{
Logging.Info("启动单实例");
OnlyInstance.Server();
});
// 绑定错误捕获
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += Application_OnException;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(Global.MainForm = new MainForm());
}
}
19
View Source File : Program.cs
License : MIT License
Project Creator : AmazingDM
License : MIT License
Project Creator : AmazingDM
public static FileInfo FindFile(string filename, string directory)
{
var DirStack = new Stack<string>();
DirStack.Push(directory);
while (DirStack.Count > 0)
{
var DirInfo = new DirectoryInfo(DirStack.Pop());
try
{
foreach (var DirChildInfo in DirInfo.GetDirectories())
{
DirStack.Push(DirChildInfo.FullName);
}
}
catch
{
// ignored
}
try
{
foreach (var FileChildInfo in DirInfo.GetFiles())
{
if (FileChildInfo.Name == filename)
{
return FileChildInfo;
}
}
}
catch
{
// ignored
}
}
return null;
}
19
View Source File : Program.cs
License : MIT License
Project Creator : AmazingDM
License : MIT License
Project Creator : AmazingDM
private static void MoveDirectory(string sourceDirName, string destDirName, bool overwrite)
{
sourceDirName = Path.GetFullPath(sourceDirName);
destDirName = Path.GetFullPath(destDirName);
if (!overwrite)
{
Directory.Move(sourceDirName, destDirName);
}
else
{
var dirStack = new Stack<string>();
dirStack.Push(sourceDirName);
while (dirStack.Count > 0)
{
var dirInfo = new DirectoryInfo(dirStack.Pop());
try
{
foreach (var dirChildInfo in dirInfo.GetDirectories())
{
var destPath = dirChildInfo.FullName.Replace(sourceDirName, destDirName);
try
{
if (!Directory.Exists(destPath))
{
Directory.CreateDirectory(destPath);
}
}
catch (Exception e)
{
Console.WriteLine($"Create {destPath} Folder Error: {e.Message}");
}
dirStack.Push(dirChildInfo.FullName);
}
foreach (var fileChildInfo in dirInfo.GetFiles())
{
var destPath = fileChildInfo.FullName.Replace(sourceDirName, destDirName);
try
{
if (File.Exists(destPath))
{
File.Delete(destPath);
}
fileChildInfo.MoveTo(destPath);
}
catch (Exception e)
{
Console.WriteLine($"Move {fileChildInfo.FullName} To {destPath} Error: {e.Message}");
}
}
}
catch (Exception e)
{
Console.WriteLine($"ERROR:{e.Message}");
}
}
}
}
19
View Source File : ModPacker.cs
License : GNU General Public License v3.0
Project Creator : AM2R-Community-Developers
License : GNU General Public License v3.0
Project Creator : AM2R-Community-Developers
private void CopyFilesRecursive(DirectoryInfo source, string[] blacklist, string destination)
{
foreach (FileInfo file in source.GetFiles())
{
if (!blacklist.Contains(file.Name))
{
file.CopyTo(destination + "\\" + file.Name);
}
}
foreach (DirectoryInfo dir in source.GetDirectories())
{
string newDir = Directory.CreateDirectory(destination + "\\" + dir.Name).FullName;
CopyFilesRecursive(dir, blacklist, newDir);
}
}
19
View Source File : Process.cs
License : MIT License
Project Creator : AmazingDM
License : MIT License
Project Creator : AmazingDM
public void ScanDirectory(string DirName)
{
try
{
var RDirInfo = new DirectoryInfo(DirName);
if (!RDirInfo.Exists)
{
return;
}
}
catch (Exception)
{
return;
}
var DirStack = new Stack<string>();
DirStack.Push(DirName);
while (DirStack.Count > 0)
{
var DirInfo = new DirectoryInfo(DirStack.Pop());
try
{
foreach (var DirChildInfo in DirInfo.GetDirectories())
{
DirStack.Push(DirChildInfo.FullName);
}
foreach (var FileChildInfo in DirInfo.GetFiles())
{
if (FileChildInfo.Name.EndsWith(".exe") && !RuleListBox.Items.Contains(FileChildInfo.Name))
{
RuleListBox.Items.Add(FileChildInfo.Name);
Edited = true;
}
}
}
catch (Exception)
{
// ignored
}
}
}
19
View Source File : DirectoryDiff.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
private void Execute(DirectoryInfo A, DirectoryInfo B, DirectoryDiffEntry Entry, bool bCheckIfFilesAreDifferent)
{
//Get the arrays of files
FileInfo[] arAFileInfos, arBFileInfos;
if (m_Filter == null)
{
arAFileInfos = A.GetFiles();
arBFileInfos = B.GetFiles();
//Sort them
Array.Sort(arAFileInfos, FileSystemInfoComparer.Comparer);
Array.Sort(arBFileInfos, FileSystemInfoComparer.Comparer);
}
else
{
arAFileInfos = m_Filter.Filter(A);
arBFileInfos = m_Filter.Filter(B);
}
//Diff them
DiffFileSystemInfos(arAFileInfos, arBFileInfos, Entry, true, bCheckIfFilesAreDifferent);
//Get the arrays of subdirectories
DirectoryInfo[] arADirInfos = A.GetDirectories();
DirectoryInfo[] arBDirInfos = B.GetDirectories();
//Sort them
Array.Sort(arADirInfos, FileSystemInfoComparer.Comparer);
Array.Sort(arBDirInfos, FileSystemInfoComparer.Comparer);
//Diff them
DiffFileSystemInfos(arADirInfos, arBDirInfos, Entry, false, bCheckIfFilesAreDifferent);
}
19
View Source File : SvnSccContext.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
private void RecursiveCopy(DirectoryInfo source, DirectoryInfo destination)
{
foreach (FileInfo sourceFile in source.GetFiles())
{
FileInfo destFile = sourceFile.CopyTo(Path.Combine(destination.FullName, sourceFile.Name));
destFile.Attributes = sourceFile.Attributes;
}
foreach (DirectoryInfo subDirSource in source.GetDirectories())
{
DirectoryInfo subDirDestination = destination.CreateSubdirectory(subDirSource.Name);
subDirDestination.Attributes = subDirSource.Attributes;
RecursiveCopy(subDirSource, subDirDestination);
}
}
19
View Source File : OfflineDataProvider.cs
License : MIT License
Project Creator : Analogy-LogViewer
License : MIT License
Project Creator : Analogy-LogViewer
protected override List<FileInfo> GetSupportedFilesInternal(DirectoryInfo dirInfo, bool recursive)
{
List<FileInfo> files = new List<FileInfo>();
foreach (string pattern in UserSettingsManager.UserSettings.Settings.SupportFormats)
{
files.AddRange(dirInfo.GetFiles(pattern).ToList());
}
if (!recursive)
{
return files;
}
try
{
foreach (DirectoryInfo dir in dirInfo.GetDirectories())
{
files.AddRange(GetSupportedFilesInternal(dir, true));
}
}
catch (Exception)
{
return files;
}
return files;
}
19
View Source File : AnalogyBuiltInFactory.cs
License : MIT License
Project Creator : Analogy-LogViewer
License : MIT License
Project Creator : Analogy-LogViewer
protected override List<FileInfo> GetSupportedFilesInternal(DirectoryInfo dirInfo, bool recursive)
{
List<FileInfo> files = dirInfo.GetFiles("*.axml")
.Concat(dirInfo.GetFiles("*.ajson"))
.Concat(dirInfo.GetFiles("*.abin"))
.ToList();
if (!recursive)
{
return files;
}
try
{
foreach (DirectoryInfo dir in dirInfo.GetDirectories())
{
files.AddRange(GetSupportedFilesInternal(dir, true));
}
}
catch (Exception)
{
return files;
}
return files;
}
See More Examples