Update WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs

Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
This commit is contained in:
Namhyeon Go 2025-11-16 18:58:48 +09:00 committed by GitHub
parent c392b6a08a
commit daea458f64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -207,25 +207,21 @@ namespace WelsonJS.Launcher
throw; throw;
} }
return workingDirectory;
var sourceDirInfo = new DirectoryInfo(sourceDir);
// Create all subdirectories
foreach (DirectoryInfo dir in sourceDirInfo.GetDirectories("*", SearchOption.AllDirectories))
{
Directory.CreateDirectory(Path.Combine(destDir, dir.FullName.Substring(sourceDirInfo.FullName.Length + 1)));
} }
private static void CopyDirectoryRecursive(string sourceDir, string destDir) // Copy all files
foreach (FileInfo file in sourceDirInfo.GetFiles("*", SearchOption.AllDirectories))
{ {
if (!Directory.Exists(sourceDir)) string targetPath = Path.Combine(destDir, file.FullName.Substring(sourceDirInfo.FullName.Length + 1));
{ file.CopyTo(targetPath, true);
throw new DirectoryNotFoundException("Source directory not found: " + sourceDir);
} }
Directory.CreateDirectory(destDir);
foreach (var file in Directory.GetFiles(sourceDir, "*", SearchOption.AllDirectories))
{
string relativePath = file.Substring(sourceDir.Length).TrimStart(
Path.DirectorySeparatorChar,
Path.AltDirectorySeparatorChar
);
string targetPath = Path.Combine(destDir, relativePath); string targetPath = Path.Combine(destDir, relativePath);
string targetDir = Path.GetDirectoryName(targetPath); string targetDir = Path.GetDirectoryName(targetPath);
if (!Directory.Exists(targetDir)) if (!Directory.Exists(targetDir))