Check the existence of a file extension in a folder

  • I have created a package to import data from a network that receives dynamic files every morning. I was just wondering, is there way to check the folder to determine whether a particular file extension such as .csv is available before the package run?

  • You can use a script task that uses the DirectoryInfo.GetFiles(string) method. You can specify a pattern, such as *.csv. If one or more filenames are returned, the extension is present.

    DirectoryInfo.GetFiles Method (String)

    Or you could loop over the files and use FileInfo.Extension to get all the extensions of the files in the current directory.

    FileSystemInfo.Extension Property

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

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

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