If the file does not exist continuously

  • Hello everyone
    I have a system task that attempts to copy files from one directory to another directory
    the pb is that my script is out in error if it does not find one of my file
    while I want my script to continue processing file copying even if there are non-existent files
    Who can help me on this need please



                Dts.TaskResult = (int)ScriptResults.Success;
        String Filepath = Dts.Variables["User::name"].Value.ToString();
        if (
        File.Exists(Filepath))
        {
          Dts.Variables["User::File_exist"].Value = 1;
          Dts.TaskResult = (int)ScriptResults.Success;



  • My French is not good enough to enable me to understand exactly what the problem is here.
    Assuming you have a list of files held somewhere, a simple script task should do the job. IN pseudo code:

    foreach (file in list)
      {
      if (File.Exists(sourceFilePath))
         {File.Copy(sourceFilePath,targetFilePath);}
      }

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Sorry I did not manage to do it

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply