mirror of
https://github.com/Barubary/dsdecmp.git
synced 2024-06-01 08:08:48 +02:00
C#: updated the generic compression/decompression functions to make sure the folder of the given output file exists before creating the file.
This commit is contained in:
parent
bd9c45a89b
commit
2c6ef5570a
|
@ -50,6 +50,10 @@ namespace DSDecmp.Formats
|
|||
/// <param name="outfile">The target location of the decompressed file.</param>
|
||||
public void Decompress(string infile, string outfile)
|
||||
{
|
||||
// make sure the output directory exists
|
||||
string outDirectory = Path.GetDirectoryName(outfile);
|
||||
if (!Directory.Exists(outDirectory))
|
||||
Directory.CreateDirectory(outDirectory);
|
||||
// open the two given files, and delegate to the format-specific code.
|
||||
using (FileStream inStream = new FileStream(infile, FileMode.Open),
|
||||
outStream = new FileStream(outfile, FileMode.Create))
|
||||
|
@ -83,6 +87,10 @@ namespace DSDecmp.Formats
|
|||
/// <returns>The size of the compressed file.</returns>
|
||||
public int Compress(string infile, string outfile)
|
||||
{
|
||||
// make sure the output directory exists
|
||||
string outDirectory = Path.GetDirectoryName(outfile);
|
||||
if (!Directory.Exists(outDirectory))
|
||||
Directory.CreateDirectory(outDirectory);
|
||||
// open the proper Streams, and delegate to the format-specific code.
|
||||
using (FileStream inStream = File.Open(infile, FileMode.Open),
|
||||
outStream = File.Create(outfile))
|
||||
|
|
Loading…
Reference in New Issue
Block a user