From 53c0d198e45042678885a544bc91c2c05d3c1c57 Mon Sep 17 00:00:00 2001 From: NintenHero <37460517+MichaelHinrichs@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:40:43 -0500 Subject: [PATCH] refactor --- Program.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Program.cs b/Program.cs index 70bcc8e..dff7dd2 100644 --- a/Program.cs +++ b/Program.cs @@ -3,17 +3,17 @@ internal class Program { private static void Main(string[] args) { - BinaryReader br = new BinaryReader(File.OpenRead(args[0])); + BinaryReader br = new(File.OpenRead(args[0])); + string path = Path.GetDirectoryName(args[0]) + "//" + Path.GetFileNameWithoutExtension(args[0]) + "//"; - int size = br.ReadInt32(); - for (int i = 0; i < size; i++) + int count = br.ReadInt32(); + for (int i = 0; i < count; i++) { string name = br.ReadString(); - Directory.CreateDirectory(Path.GetDirectoryName(args[0]) + "//" + Path.GetFileNameWithoutExtension(args[0]) + "//" + Path.GetDirectoryName(name)); - using FileStream FS = File.Create(Path.GetDirectoryName(args[0]) + "//" + Path.GetFileNameWithoutExtension(args[0]) + "//" + name); - BinaryWriter bw = new(FS); + Directory.CreateDirectory(path + Path.GetDirectoryName(name)); + BinaryWriter bw = new(File.Create(path + name)); bw.Write(br.ReadBytes(br.ReadInt32())); bw.Close(); } } -} \ No newline at end of file +}