我正在制作一个软件,它将文件从下载文件夹移动到目录中的特定子文件夹。用户通过组合框选择子文件夹。我不断收到此错误:System.IO.IOException: Cannot create a file when that file already exists.
此外,这些错误出现在安装我的程序的人的计算机上......异常和事情。我怎么关掉它。另外,为什么我会收到此错误?这是我的代码:
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);
if (comboBox1.Text == "Select File Destination")
{
MessageBox.Show("Please Select A Destination Folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}