Dear all,
Could you tell me which code of vb scrip that i can check file size as follow ?
Dim FSO, Fyl
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fyl = CreateObject("File")
If FSO.FileExists("C:\temp\lcbseg.log") Then
Set Fyl = FSO.GetFile("C:\temp\lcbseg.log")
If Fyl.Size > 0 Then
Main = DTSStepScriptResult_ExecuteTask
Else
Main = DTSStepScriptResult_DontExecuteTask
End If
End if
Thanks
Best regards,
Kusuma
You need to do this in two stages, since there is no workflow script anymore.
Here is a sample for nthe Script Task. It uses a variable called FileSize, into which it stores the file size, surpirse!
Public Sub Main()
Dim info As System.IO.FileInfo = New System.IO.FileInfo("C:\File.txt")
Dim variables As New Variables
Dts.VariableDispenser.LockOneForWrite("FileSize", variables)
variables(0).Value = info.Length
variables.Unlock()
Dts.TaskResult = Dts.Results.Success
End Sub
Now you would use a precedenc constraint from the sript task to the next task, but be sure to include an expression. Double-click to get the UI, and try and expression like this-
@.[Use::FileSize] > 0
|||
I've tried to follow your code DarrenSQLIS, but it has the error "FileSize" for read/write access with error 0xC0010001 "The variable cannot be found. how can i fix this problem?
So i've some questions where can i declare FileSize variable. It's on SSIS menu=> varible,isn't it? and what's type of FileSize variable. For next what's property of expresstion to use @.[Use::FileSize] > 0.
Many thanks.
Best Regards,
Kusuma
|||I know you asked how do check for a file size equal to non zero in a script task, which can certainly be done with a script task as Darren illustrates.Another technique for checking file existence and size simultaneously is use of "WMI Data Reader Task" with WQL. Use of the WMI data reader task will require a WMI connection manager, which is quick simple to configure, and available through the task's UI.
For example, the following WQL query checks for the existence and size of c:\boot.ini. simultaneously.
Select FileSize From CIM_Datafile Where Name = 'C:\\boot.ini'
After the WMI task, a downstream task can constrained by the following expression, which evaluates to true only for an existent, non zero byte file.
@.FileLength > "0\r\n"
NOTE, in this case, @.FileLength is a string variable, unlike the script task case. The reason the variable for file size is a string rather than a uint64 is that the WMI Data Reader task writes string and/or object variable types. The backslash is a special character to WMI, and as such is doubled up (escaped) in the WQL query.|||
|||Hey hi . Could you tell me a VB code so that I can check a file size in a folder and mail to abc@.xyz.com if the file size is less than 10MB?|||First of all read the code above, it shows you how to get the file size into a variable. Then use an SMTP Send Mail Task to send the mail. To restrict the email to only files < 10MB, add an expression on the precendence constraint between the Script Task and Mail Task, @.Var < 10000KUS wrote: Dear all,
Could you tell me which code of vb scrip that i can check file size as follow ?
Dim FSO, Fyl
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fyl = CreateObject("File")If FSO.FileExists("C:\temp\lcbseg.log") Then
Set Fyl = FSO.GetFile("C:\temp\lcbseg.log")
If Fyl.Size > 0 Then
Main = DTSStepScriptResult_ExecuteTask
Else
Main = DTSStepScriptResult_DontExecuteTask
End If
End ifThanks
Best regards,
Kusuma
No comments:
Post a Comment