FileSystem.CopyFile(fSource, fTarget, UIOption.AllDialogs, UICancelOption.DoNothing);
                                            foreach (ListViewItem checkItem in listView_left.Items)
                                            {

                                                if (checkItem.Text == lItem.Text)
                                                {
                                                    listView_left.Items.Remove(checkItem);
                                                }
                                            }
                                            listView_left.Items.Add((ListViewItem)lItem.Clone());
                                            reload(lItem, fSource);

how can i return the UIOption.AllDialogs value so if it's cancel it doesnt do the code after the first line?

Perhaps this:

try
{
    FileSystem.CopyFile(fSource, fTarget, UIOption.AllDialogs, UICancelOption.ThrowException);  // Throw exception if user cancels
    foreach (ListViewItem checkItem in listView_left.Items)
    {
        if (checkItem.Text == lItem.Text)
        {
            listView_left.Items.Remove(checkItem);
        }
    }
    listView_left.Items.Add((ListViewItem)lItem.Clone());
    reload(lItem, fSource);
}
catch (OperationCanceledException ocex)
{
    // The user canceled
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.