Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 复制和重命名文件VB脚本不适用于SSIS脚本任务_Vb.net_File_Ssis_Copy_Script Task - Fatal编程技术网

Vb.net 复制和重命名文件VB脚本不适用于SSIS脚本任务

Vb.net 复制和重命名文件VB脚本不适用于SSIS脚本任务,vb.net,file,ssis,copy,script-task,Vb.net,File,Ssis,Copy,Script Task,我正在使用Excel模板为SSIS包动态创建报告。我试图复制Excel模板,并在脚本任务对象中使用VB 2010对其进行重命名 以下是我的代码: Public Sub Main() Dim sourcePath As String = "\\server\Dir1\Dir2\Dir3\FileName_TEMPLATE.xlsx" Dim destPath As String = "\\server\Dir1\Dir2\Dir3\FileName" + CDate(Date

我正在使用Excel模板为SSIS包动态创建报告。我试图复制Excel模板,并在脚本任务对象中使用VB 2010对其进行重命名

以下是我的代码:

 Public Sub Main()

    Dim sourcePath As String = "\\server\Dir1\Dir2\Dir3\FileName_TEMPLATE.xlsx"

    Dim destPath As String = "\\server\Dir1\Dir2\Dir3\FileName" + CDate(Date.Today.Date).ToString("yyyyMMdd") + ".xlsx"


    If File.Exists(destPath) = True Then

        File.Delete(destPath)       'delete existing file'
        File.Copy(sourcePath, destPath)         'copy template file and rename'

    End If

    Dts.TaskResult = ScriptResults.Success

End Sub

End Class
我将
如果File.Exists(destPath)=True然后…
更改为
如果File.Exists(sourcePath)=True…
以查看
源路径是否存在,然后添加了一个
消息框(“文件不存在”)
ELSE
语句中,如果源文件存在并且返回
消息框
声明

"File doesn't exist"
模板文件就在那里,我将地址从Windows资源管理器窗口复制并粘贴到
sourcePath
字符串,以确保路径的准确性

sourcePath
位于不同的服务器上

文件位于源路径中

我做错了什么


谢谢

您的文件中有一些非法字符,不是吗<代码>“…Dir3\FileName2/26/2015.xlsx”
oops…很抱歉…我之前注意到了,并删除了非法字符…仍然说文件不存在…我可能会对问题进行编辑?因此…它不起作用,因为我打开了文件存在的目录。我关闭了目录并重新运行,现在开始工作。简言之……我这方面的白痴行动;)