Solved

How to find each file size in the given folder via SSIS?

Posted on 2008-10-28
3
1,922 Views
Last Modified: 2013-11-10
My Client is transferring 83 specific files every one hour in one particular folder.
1.I need to find out each file size in the folder
2.If any one of the file sizes is 10 times bigger than that particular file average size then need to send email to my team via SSIS.
Can you help me how to do in SSIS?
Thanks.
0
Comment
Question by:PKTG
[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
3 Comments
 
LVL 17

Assisted Solution

by:HoggZilla
HoggZilla earned 75 total points
ID: 22825512
Create a Foreach Loop Container to loop through all files in the specified directory. Use the Variable Mappings in the Foreach Loop Editor to assign the filename  to a variable.
Within the Container, add a script task. Here is a snippet to help.

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.IO.File
Imports System.IO.FileInfo
 
 
 
Public Sub Main()
        Dim LoopFileName As String = CStr(Dts.Variables("LoopFileName").Value)
        Dim Path As String = CStr(Dts.Variables("FileShareDirectory").Value)
        Dim LoopFilePath As String = Path + LoopFileName
        Dim File As System.IO.File
        Dim FileInfo As System.IO.FileInfo
 
        Dim CheckFileDate As DateTime = File.GetCreationTime(LoopFilePath)
        Dim FileDate As DateTime = CDate(Dts.Variables("FileDate").Value)
        Dim FileSize As Long = FileInfo.Length
End Sub

Open in new window

0
 
LVL 22

Accepted Solution

by:
PedroCGD earned 175 total points
ID: 22825921
Dear Friend,
Create a new SSIS Project, rename the attached file and add it to this new project.
This package will read each file in C:\ and will apper a msgbox with all path and other msgbox with the filesize. (The size is in Bytes)
Test it and customize it!
If you need some help, please let me know!
regards!
Pedro
www.pedrocgd.blogspot.com
Package-EE38-dtsx.txt
FileSize.JPG
0
 

Author Closing Comment

by:PKTG
ID: 31510916
Thanks fo the attachment. It is very helpfull for beginners in SSIS like me. I really appreciate it. If i need furthur clarification , i will let you know.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

710 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