private void button1_Click(object sender, EventArgs e)
{
string newPath = "";
string path = @"E:\test\novel";
string oldPath = "";
string Suffix = "";
newPath = path + @"\" + comboBox1.Text + @"\" + textBox1.Text;
CreateDirectory(newPath);
OpenFileDialog dialog = new OpenFileDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
oldPath = dialog.FileName;
Suffix = oldPath.Substring(oldPath.IndexOf('.') + 1, oldPath.Length - (oldPath.IndexOf('.') + 1));
}
MoveFile(oldPath, newPath + @"\" + DateTime.Now.ToString("yyyyMMddHHmmss") + "." + Suffix);
}
private void button2_Click(object sender, EventArgs e)
{
string newPath = "";
string path = @"E:\test\novel";
string oldPath = "";
string Suffix = "";
newPath = path + @"\" + comboBox2.Text + @"\" + textBox2.Text;
CreateDirectory(newPath);
OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = true;
if (dialog.ShowDialog() == DialogResult.OK)
{
int i = 0;
foreach (string file in dialog.FileNames)
{
oldPath = file;
Suffix = oldPath.Substring(oldPath.IndexOf('.') + 1, oldPath.Length - (oldPath.IndexOf('.') + 1));
MoveFile(oldPath, newPath + @"\" + DateTime.Now.ToString("yyyyMMddHHmmss") + i.ToString() + "." + Suffix);
i++;
}
}
}
public void CreateDirectory(string Path)
{
Directory.CreateDirectory(Path);
}
public void MoveFile(string oldPath,string newPath)
{
File.Move(oldPath, newPath);
}