Skip to content

Commit

Permalink
fix(domain): create the containing dir of user config before writing …
Browse files Browse the repository at this point in the history
…the file
  • Loading branch information
lars-berger committed Apr 4, 2022
1 parent 476f025 commit c1def0b
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ private void InitializeSampleUserConfig(string userConfigPath)
var assembly = Assembly.GetEntryAssembly();
var sampleConfigResourceName = "GlazeWM.Bootstrapper.sample-config.yaml";

// Create containing directory. Needs to be created before writing to the file.
Directory.CreateDirectory(Path.GetDirectoryName(userConfigPath));

// Get the embedded sample user config from the entry assembly.
using (Stream stream = assembly.GetManifestResourceStream(sampleConfigResourceName))
{
// Write the sample user config to the appropriate destination.
using (var fileStream = new FileStream(userConfigPath, FileMode.Create, FileAccess.Write))
{
Directory.CreateDirectory(Path.GetDirectoryName(userConfigPath));
stream.CopyTo(fileStream);
}
}
Expand Down

0 comments on commit c1def0b

Please sign in to comment.