Skip to content

Commit

Permalink
Changes to destination folder selection and added hide source folder …
Browse files Browse the repository at this point in the history
…after completion
  • Loading branch information
imDema committed Oct 29, 2016
1 parent 611cf96 commit db73fa6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
3 changes: 1 addition & 2 deletions FreeMove/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 17 additions & 10 deletions FreeMove/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,31 @@ public Form1()

private void button_Move_Click(object sender, EventArgs e)
{
string from, to;
from = textBox_From.Text;
to = textBox_To.Text;
string source, destination;
source = textBox_From.Text;
destination = textBox_To.Text + "\\" + Path.GetFileName(source);

if (CheckFolders(from, to ))
if (CheckFolders(source, destination ))
{
Directory.Move(from, to);
Directory.Move(source, destination);
Process mkink = new Process();
mkink.StartInfo.FileName = "cmd.exe";
mkink.StartInfo.Arguments = "/c mklink /j " + from + " " + to;
mkink.StartInfo.Arguments = "/c mklink /j " + source + " " + destination;
mkink.StartInfo.UseShellExecute = false;
mkink.StartInfo.RedirectStandardOutput = true;
mkink.Start();

string output = mkink.StandardOutput.ReadToEnd();
mkink.WaitForExit();
WriteLog(output);

if(checkBox1.Checked)
{
DirectoryInfo olddir = new DirectoryInfo(source);
var attrib = File.GetAttributes(source);
olddir.Attributes = attrib | FileAttributes.Hidden;
}

MessageBox.Show(ReadLog());
}
else
Expand Down Expand Up @@ -77,12 +85,12 @@ private bool CheckFolders(string frompath, string topath)
}
if (Directory.Exists(topath))
{
errors += "ERROR, destination folder already exists";
errors += "ERROR, destination folder already contains a folder with the same name";
passing = false;
}
if(!Directory.Exists(Directory.GetParent(topath).FullName))
if (!Directory.Exists(Directory.GetParent(topath).FullName))
{
errors += "ERROR, parent of destination folder doesn't exist";
errors += "destination folder doesn't exist";
passing = false;
}

Expand Down Expand Up @@ -123,7 +131,6 @@ private string ReadLog()
private string GetTempFolder()
{
string dir = Environment.GetEnvironmentVariable("TEMP") + @"\FreeMove";
//if(!Directory.Exists(dir))
Directory.CreateDirectory(dir);
return dir;
}
Expand Down

0 comments on commit db73fa6

Please sign in to comment.