Exclude specific Sub Folders

前端 未结 4 482
生来不讨喜
生来不讨喜 2020-12-11 07:37

I got a package that runs through a folder and it\'s sub folders to get client data. The agreement has changed and now the client will post his data in different folder name

4条回答
  •  一生所求
    2020-12-11 07:39

    you may have a more control, if you use Script task

    Here is the sample code which I have used in one of SSIS:

     // Fetch Exclude Directory list from Table
            List excludeDir = new List();
            SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\testDB.mdf;Integrated Security=True;User Instance=True");
            SqlCommand cmd = new SqlCommand("select DirList from excludeDir", conn);
            SqlDataReader dr;
            try
            {
                conn.Open();
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    excludeDir.Add(new excludeDir()
                    {
                        Dir = dr.GetInt32(dr.GetOrdinal("DirList")),
    
                    });
    
                }
                dr.Close();
            }
            catch (Exception exp)
            {
    
                throw;
            }
            finally
            {
    
                conn.Close();
            }
    // compare against Sub directory list and process
    string[] dirs = Directory.GetDirectories(@"C:\My Sample Path\");
    string[] fileExclude = excludeDir ;
    foreach (string path in dirs)
        {
            FileInfo f = new FileInfo(item2);
    
            listBox1.Items.Add(f.Name);
    
            for (int i = 0; i < fileExclude.Length; i++)
           {
    
               -- Console.WriteLine(fileArray[i]);
    
               IF dirs [i] == fileExclude [i]
               {
                //Set Flags accordingly and execute 
               }
           }
    
        }
    

提交回复
热议问题