You need to start by looking at the content of your files: since you load the
script
from each file in turn and execute it, you need to use the debugger to find out exactly what is in the script it fails on.
script = File.ReadAllText(pa);
...
server.ConnectionContext.ExecuteNonQuery(script);