ssis - how to check file exists

nononame2021 261 Reputation points
2021-11-17T10:44:47.403+00:00

I have to import 3 excels into database, my input path is variable. how can I check files exists, if don't exists, then it will not process the import task, and go end task. if file exists, then go import file task.

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,702 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Yitzhak Khabinsky 26,586 Reputation points
    2021-11-17T12:52:40.213+00:00
    1 person found this answer helpful.
    0 comments No comments

  2. CarrinWu-MSFT 6,891 Reputation points
    2021-11-18T03:09:37.55+00:00

    Hi @nononame2021 ,

    Thanks for your question.

    Please refer to below steps:
    150385-exist.png
    150386-exist2.png
    150300-exist3.png

    ...  
    using System.IO;  
    ...  
    Dts.Variables["Exists"].Value = File.Exists(Dts.Variables["FilePath"].Value.ToString());  
                MessageBox.Show(Dts.Variables["FilePath"].Value.ToString());  
                MessageBox.Show(Dts.Variables["Exists"].Value.ToString());  
    

    For more information, please refer to this vedio.

    Best regards,
    Carrin


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. nononame2021 261 Reputation points
    2021-11-18T03:15:37.047+00:00

    how to go end flow if file not exists.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.