I made my IO exception and everything to copy a file to an existing spot and then overwrite it. I programmed the IO fine, but I get the error saying 'File in use'
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace IO
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void buttonX1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
try
{
string filename = (Application.StartupPath + "\\update.html");
string sourcepath = (Application.StartupPath + "\\update.html");
string targetpath = @"C:\TestProject";
string sourcefile = System.IO.Path.Combine(sourcepath, filename);
string destfile = System.IO.Path.Combine(targetpath, filename);
System.IO.File.Copy(sourcefile, destfile, true);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
progressBarX1.Minimum = 0;
progressBarX1.Maximum = 100;
progressBarX1.Step = 1;
progressBarX1.PerformStep();
}
}
}