Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Check if File exist - Script Task

$
0
0
I am trying to write a logic within SSIS 2014 using script task (script lang:Microsoft Visual C# 2012) where it looks if text file exist or not and returns a value (1,0) in varibale : User::FileExistFlgBelow is the code that i have used and i am not sure why its giving me an error. #region Namespacesusing System;using System.IO;using System.Data;using Microsoft.SqlServer.Dts.Runtime;using System.Windows.Forms;#endregionnamespace ST_d30d883df9b74e2ca208991af5660938{ public void Main() { // TODO: Add your code here String Filepath = Dts.Variables["User::FileLocation"].Value.ToString() + Dts.Variables["User::FileName"].Value.ToString(); if ( File.Exists(Filepath)) { Dts.Variables["User::FileExistFlg"].Value = 1; } MessageBox.Show(Filepath); MessageBox.Show(Dts.Variables["User::FileExistFlg"].Value.ToString()); Dts.TaskResult = (int)ScriptResults.Success; }[b] And below is the error i am getting [/b] at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()Thank you for the help in advance!

Viewing all articles
Browse latest Browse all 3145

Trending Articles