When you get the error you should also get a stack trace which indicates what line the exception was thrown from.

Without the trace/line numbers I can only venture a guess (without actually implementing the code), but my eyes goes to the:
Code:
XmlNode test2;
...
test.Load(txtBoxSourceFilePath.Text);
lines as the likely culprit.

If not those being the issue verify your outfilewriter is not null and similar.

But advice - check the stacktrace and the linenumber of the exception thrown.