Hi All,
I am writing this code in windows form where user provides
SOURCE path and
DESTINATION path manually in textbox.
And there is a button called COPY.
After clicking on copy, the files inside Source folder should copy to Destination folder
But it is throwing an error at source path stating
'Access to the path 'C:\Users\XXXX\Desktop\SOURCE' is denied.'
Can anyone help me on this and below is the code on BUTTON click.
NOTE: On a button click, another form opens. So the code below provided is on form opening on button click
CODE:
private void button2_Click(object sender, EventArgs e)
{
source = textBox1.Text;
destination = textBox2.Text;
thresholdvalue = textBox3.Text;
var extensions = new[] { ".tif", ".tiff", ".jpg", ".jpeg" };
foreach (var sourceFilePath in Directory.GetFiles(source))
{
string fileName = Path.GetFileName(sourceFilePath);
string destinationFilePath = Path.Combine(destination, fileName);
System.IO.File.Copy(source, destinationFilePath, true);
}
}
CODE ERROR IN MAIN PAGE:
private void button2_Click(object sender, EventArgs e)
{
try
{
ReadOPT.Files_Copy_to_DeliveryPath f = new ReadOPT.Files_Copy_to_DeliveryPath();
f.ShowDialog();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
What I have tried:
I tried changing the permissions or owner on the SOURCE folder by right click and properties butsame issue