For some reason, the user that installs this, when they click the button, nothing happens. Also, if i take the try and catch, it says the file already exists, and it does not. The sub folder does, but not the file. What is wrong? Here is my code:
string pathUser4 = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string pathDownload4 = (pathUser4 + @"\Downloads\");
string sourceFile = pathDownload4 + listBox1.Text;
string pathdoc5 = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string pathDownload5 = (pathdoc5 + @"\iracing\setups\");
string destinationFile = pathDownload5 + comboBox1.Text;
File.Move(sourceFile, destinationFile);
}
catch { }
if (comboBox1.Text == "Select File Destination")
{
MessageBox.Show("Please Select A Destination Folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
I think your first problem is your checking the comboBox1.Text for a proper value AFTER you’ve attempted to move the file.
Second use the Path object as MichelZ suggested. It’s easier and should not cause any issue.
Here is what your code would like with the changes: