Skip to content

Commit

Permalink
D&D: user's temp folder instead of application path
Browse files Browse the repository at this point in the history
  • Loading branch information
kwsch committed Nov 14, 2015
1 parent f867697 commit 72e149d
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions PKX/f1-Main.cs
Expand Up @@ -2393,7 +2393,6 @@ private void dragout_MouseDown(object sender, MouseEventArgs e)
if (!verifiedPKX()) { return; }
{
// Create Temp File to Drag
string basepath = Application.StartupPath;
Cursor.Current = Cursors.Hand;

// Make a new file name
Expand All @@ -2409,14 +2408,11 @@ private void dragout_MouseDown(object sender, MouseEventArgs e)
// Strip out party stats (if they are there)
Array.Resize(ref dragdata, PK6.SIZE_STORED);
// Make file
string newfile = Path.Combine(basepath, Util.CleanFileName(filename));
string newfile = Path.Combine(Path.GetTempPath(), Util.CleanFileName(filename));
try
{
File.WriteAllBytes(newfile, dragdata);

string[] filesToDrag = { newfile };
dragout.DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Move);
File.Delete(newfile);
DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move);
}
catch (Exception x)
{ Util.Error("Drag & Drop Error", x.ToString()); }
Expand Down Expand Up @@ -3264,7 +3260,6 @@ private void pbBoxSlot_MouseDown(object sender, MouseEventArgs e)
int offset = getPKXOffset(pkm_from_slot);
if (e.Button != MouseButtons.Left || e.Clicks != 1) return;
// Create Temp File to Drag
string basepath = Application.StartupPath;
Cursor.Current = Cursors.Hand;

// Prepare Data
Expand All @@ -3281,14 +3276,11 @@ private void pbBoxSlot_MouseDown(object sender, MouseEventArgs e)
filename += " - " + pkx.PID + ".pk6";

// Make File
string newfile = Path.Combine(basepath, Util.CleanFileName(filename));
string newfile = Path.Combine(Path.GetTempPath(), Util.CleanFileName(filename));
try
{
File.WriteAllBytes(newfile, dragdata);

string[] filesToDrag = { newfile };
DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Move);
File.Delete(newfile); // after drop, delete the temporary file
DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move);
}
catch (ArgumentException x)
{ Util.Error("Drag & Drop Error:", x.ToString()); }
Expand Down

0 comments on commit 72e149d

Please sign in to comment.