Skip to content

Commit

Permalink
Create target directories when copying over new files
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Jul 18, 2023
1 parent 0b57531 commit 820b7e1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Onova.Updater/Utils/DirectoryEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@ public static void Copy(string sourceDirPath, string destDirPath, bool overwrite
{
foreach (var sourceFilePath in Directory.GetFiles(sourceDirPath, "*", SearchOption.AllDirectories))
{
var destFilePath = Path.Combine(
destDirPath,
PathEx.GetRelativePath(sourceDirPath, sourceFilePath)
);

var sourceStream = File.Open(
sourceStreams.Add(File.Open(
sourceFilePath,
FileMode.Open,
FileAccess.Read,
FileShare.Read
));

var destFilePath = Path.Combine(
destDirPath,
PathEx.GetRelativePath(sourceDirPath, sourceFilePath)
);

sourceStreams.Add(sourceStream);
Directory.CreateDirectory(
Path.GetDirectoryName(destFilePath) ?? destDirPath
);

var destStream = File.Open(
destStreams.Add(File.Open(
destFilePath,
overwrite
? FileMode.OpenOrCreate
: FileMode.CreateNew,
FileAccess.ReadWrite,
FileShare.None
);

destStreams.Add(destStream);
));
}

// Copy data from the source files to the destination files
Expand Down

0 comments on commit 820b7e1

Please sign in to comment.