title: Using Variables in Script Task in SSIS
body: <p>I am using a SSIS package with an Execute SQL Task connected to Script Task. The values from Execute SQL Task are stored in a variable and in the Script Task I use the following code to give XML file.</p>
  
  <pre><code>Public Sub Main()
      If My.Computer.FileSystem.FileExists("C:\SAMPLE.xml") Then
          Dts.TaskResult = ScriptResults.Failure
      Else
          My.Computer.FileSystem.WriteAllText("C:\SAMPLE.xml", Dts.Variables(0).Value.ToString, False)
          Dts.TaskResult = ScriptResults.Success
          ''
      End If
  End Sub    
  </code></pre>
  
  <p>I don't want to hardcode the path to XML. So I created two new variables FileName and FilePath with package as scope. How do I edit my VB.Net code to actually use these two variables.I tried this but did not work:</p>
  
  <pre><code>    Sub Main()
      If My.Computer.FileSystem.FileExists(Dts.Variables("FileDest").Value.ToString())        Else
          My.Computer.FileSystem.WriteAllText(Dts.Variables("FileDest").Value.ToString(), Dts.Variables(0).Value.ToString, False)Dts.TaskResult = ScriptResults.Success
     ''
      End If
  End Sub
  </code></pre>
  
  <p>Ideally I want to use two variables one for name and one for path but when I tried with a single variable which combines both, it didn't work.</p>