SolvedPrivate

looping over files inside sub-sub folder

Posted on 2015-02-18
7
50 Views
Last Modified: 2016-06-19
i am very new to ssis and have a task to do. i have a folder named companies and inside that folder have two sub folders named: subfolder1 & subfolder2 and inside those subfolders i have sub-subfolders

companies
      -subfolder1
            --company1-A
                                       --file1.txt
                                       --file2.txt
            --company1-B
                                       --file1a.txt
      -subfolder2
            --company2-A
                                        --file1b.txt
            --company2-B

inside those company1-A, company1-B, company2-A & company2-B folders have text files which i want to loop over and print the name of the files along with the subfolder names(subfolder1 & subfolder2). hope my question is understandable. any feedback, comments & opinion would be deeply appreciated.
0
Comment
Question by:s_hausen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 40618631
Hi,
solution for getting all files in a script task:
string[] allFiles = System.IO.Directory.GetFiles("C:\companies", "*.txt", System.IO.SearchOption.AllDirectories)

Open in new window


Other way would be to recursively run through the base directory, get files, get subdirectories, ...

Would the file name array (each being the complete path to the file) be enough? Or do you really need the distinct folder names as well?

What version of SSIS/SQL Server?
Thanks.
HTH
Rainer
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40618862
It's probably a stupid question, but why don't you use a specific file cataloger such as Filecats Standard, if all you need to do is print the file names?
0
 

Author Comment

by:s_hausen
ID: 40619151
i know its sound stupid but for right now, i just want to print the names of the sub folders and files inside sub-subfolder. the thing i'm looking is basically loop over that specific directory, print name of the files inside sub-subfolder,  and name of subdirectories. i'm using sql server 2012 and dts.
so if someone help me regarding this issue would be deeply appreciated.
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40619157
No, no - that's not stupid at all. I just want to know why you need to do it in SQL Server instead of using a separate cataloging program like the one I mentioned.
0
 

Accepted Solution

by:
s_hausen earned 0 total points
ID: 40625864
i got the solution from google:
http://microsoft-ssis.blogspot.com/2011/01/foreach-folder-enumerator.html

do appreciate everyone's input and help.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Make borderless form movable by user 2 24
rolling count by date, hour query 7 26
HIghlights of SSIS? 3 40
when sa SQL Login becomes locked 6 23
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question