I have an SSIS package that does the following;
- Detects if a file (excel exists)
- Deletes file
- Copies file from a directory into the required one
This package when run locally to test functions correctly there are no issues.
When running on server or as a job I get the error of
Exception has been thrown by the target of an invocation.
I believe the error to be based around the copy code line, as commenting this out still allows the package to run.
My version of Visual Studio is 2013 (unable to upgrade) and the SQL-Server machine is running the latest version of 2016.
The account used to run the job is considered a network administrator - the error persists.
Imports System.IO (etc)
Public Sub Main()
Dim sourcePath As String = "\\server\File\Template.xlsx"
Dim destPath As String = "\\server\File\NewFile.xlsx"
If File.Exists(destPath) = True Then
File.Delete(destPath) 'deletes current file
End If
File.Copy(sourcePath, destPath)
Dts.TaskResult = ScriptResults.Success
End Sub
I wouldn't expect any issues doing this, as other packages (different functions etc.) work as they should.