// Сначала проверяем корневой каталог
string assemblyPath = Path.Combine(baseDirectory, assemblyFileName);
if (File.Exists(assemblyPath))
{
return Assembly.LoadFrom(assemblyPath);
}
// Затем проверяем поддиректории в директории ‘MyDllFolder’
string[] subfolders = { "ru", "de", "it", "ja", "es", "fr", "hu", "pt", "sk", "sv", "tr", "zh-cn", "zh-tw", "x86", "x64" };
string customAssemblyPath = Path.Combine(baseDirectory, "MyDllFolder");
foreach (string subfolder in subfolders)
{
assemblyPath = Path.Combine(customAssemblyPath, subfolder, assemblyFileName);
if (File.Exists(assemblyPath))
{
return Assembly.LoadFrom(assemblyPath);
}
}
// Если файл не найден ни в корневом каталоге ни в подпапках MyDllFolder
return null;
}
private void MoveDirectoriesWithContent()
{
string sourcePath = AppDomain.CurrentDomain.BaseDirectory; // Путь к корневой папке
string destinationPath = Path.Combine(sourcePath, "MyDllFolder");
string[] languageFolders = { "ru", "de", "it", "ja", "es", "fr", "hu","pt","sk","sv","tr","zh-cn","zh-tw","x86","x64" };
foreach (string folder in languageFolders)
{
string sourceFolder = Path.Combine(sourcePath, folder);
string destinationFolder = Path.Combine(destinationPath, folder);
// Перемещаем папку и её содержимое, если она существует
if (Directory.Exists(sourceFolder))
{
// Если целевая папка уже существует, сначала её нужно удалить
if (Directory.Exists(destinationFolder))
{
Directory.Delete(destinationFolder, true); // true позволяет удалять рекурсивно
}
string rootFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MyDllFolder");
// Создаем корневую папку, если она еще не существует
if (!Directory.Exists(rootFolder))
{
Directory.CreateDirectory(rootFolder);
}
Directory.Move(sourceFolder, destinationFolder);
}
}
// Перемещение конкретных файлов
string[] filesToMove = { "Emgu.CV.UI.dll", "Emgu.CV.UI.xml", "Emgu.CV.World.dll", "Emgu.CV.World.xml", "ZedGraph.dll", "ZedGraph.xml" };
foreach (string fileName in filesToMove)
{
string sourceFile = Path.Combine(sourcePath, fileName);
string destinationFile = Path.Combine(destinationPath, fileName);
if (File.Exists(sourceFile))
{
if (File.Exists(destinationFile))
{
File.Delete(destinationFile); // Удалить существующий файл, если он есть
}
File.Move(sourceFile, destinationFile); // Перемещаем файл
}
}
}