Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Commit

Permalink
grammar, citations, comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TBirdSoars committed Nov 21, 2021
1 parent fdc3389 commit aa9a04b
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,21 +208,21 @@ private static async Task DownloadArchive(Uri uri, string dest)
{
try
{
using (HttpResponseMessage httpResponseMessage = await client.GetAsync(uri))
using (HttpResponseMessage message = await client.GetAsync(uri))
{
if (httpResponseMessage.StatusCode != HttpStatusCode.OK)
if (message.StatusCode != HttpStatusCode.OK)
{
Console.WriteLine("Downlaod Error: Did not receive 200 OK status code.");
return;
}

if (httpResponseMessage.Content == null)
if (message.Content == null)
{
Console.WriteLine("Downlaod Error: Response message content was null.");
return;
}

using (Stream stream = await httpResponseMessage.Content.ReadAsStreamAsync())
using (Stream stream = await message.Content.ReadAsStreamAsync())
{
FileInfo fileInfo = new FileInfo(dest);

Expand Down Expand Up @@ -277,6 +277,7 @@ private static void ExtractArchive(string src)

// Moves everything from within source folder to destination folder,
// then deletes source folder
// https://stackoverflow.com/questions/48248807/move-certain-files-to-a-folder-in-the-fastest-way-possible
private static void MoveAll(string src, string dest)
{
try
Expand All @@ -286,18 +287,18 @@ private static void MoveAll(string src, string dest)
string[] files = Directory.GetFiles(src);
string[] folders = Directory.GetDirectories(src);

// Move the files and overwrite destination files if they already exist.
// Move the files
foreach (string file in files)
{
string oldFile = Path.Combine(dest, Path.GetFileName(file));

// Delete all files with same name
// Delete existing files with same name
if (File.Exists(oldFile))
{
File.Delete(oldFile);
}

// Use static Path methods to extract only the file name from the path.
// Move new files to destination
string fileName = Path.GetFileName(file);
string destFile = Path.Combine(dest, fileName);
File.Move(file, destFile, true);
Expand All @@ -308,10 +309,10 @@ private static void MoveAll(string src, string dest)
{
string oldFolder = Path.Combine(dest, Path.GetFileName(folder));

// Delete all folders with same name, starting with contents
// Delete existing folders with same name
if (Directory.Exists(oldFolder))
{
// Delete contents of old folder
// Must delete folder contents first
DirectoryInfo di = new DirectoryInfo(oldFolder);
foreach (FileInfo file in di.GetFiles())
{
Expand All @@ -326,7 +327,7 @@ private static void MoveAll(string src, string dest)
Directory.Delete(oldFolder);
}

// Use static Path methods to extract only the folder name from the path.
// Move new folders to destination
string folderName = Path.GetFileName(folder);
string destFolder = Path.Combine(dest, folderName);
Directory.Move(folder, destFolder);
Expand All @@ -337,7 +338,7 @@ private static void MoveAll(string src, string dest)
}
else
{
Console.WriteLine($"{src} and {dest} do not exist!");
Console.WriteLine($"{src} or {dest} does not exist!");
}
}
catch (Exception ex)
Expand Down

0 comments on commit aa9a04b

Please sign in to comment.