Skip to content

Commit

Permalink
allow folder and fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
trivalik committed Dec 4, 2022
1 parent 34276f6 commit d5339b4
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions uploader/uploader/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,45 @@ private void MainForm_DragDrop(object sender, DragEventArgs e)
{
var settings = Settings.LoadSettings();

var files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (var file in files)
{
var uploadForm = new UploadForm(this, settings, true, file);
uploadForm.Show();
this.Hide();
var filesOrFolders = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (var fileOrFolder in filesOrFolders)
{
ProcessPath(settings, fileOrFolder, true);
}
}

}

private void MainForm_Shown(object sender, EventArgs e)
{
var settings = Settings.LoadSettings();
var args = Environment.GetCommandLineArgs();

if (args.Length == 2)
{
var file = args[1]; // Second argument because .NET puts program filename to the first
var uploadForm = new UploadForm(this, settings, false, file);
uploadForm.Show();
this.Hide();
var fileOrFolder = args[1]; // Second argument because .NET puts program filename to the first
ProcessPath(settings, fileOrFolder, false);
}
}
}

private void ProcessPath(Settings settings, string fileOrFolder, bool reopen)
{
if (Directory.Exists(fileOrFolder))
{
foreach (var file in Directory.GetFiles(fileOrFolder))
{
ProcessFile(settings, file, reopen);
}
}
else
{
ProcessFile(settings, fileOrFolder, reopen);
}
}

private void ProcessFile(Settings settings, string file, bool reopen)
{
var uploadForm = new UploadForm(this, settings, reopen, file);
uploadForm.Show();
Hide();
}
}
}

0 comments on commit d5339b4

Please sign in to comment.