Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Function Main()

                dim strFeedFileName

               

               Const ForReading = 1, ForWriting = 2, ForAppending = 8

                Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

 

                strFeedFileName = DTSGlobalVariables("gFeedFileName").Value

 

                ' Check if file exists and size is > 0 and not a junk by checking first line

                Dim fs, f, s, t, strData, strAllocDate

 

                Set fs = CreateObject("Scripting.FileSystemObject")

                if not fs.FileExists(strFeedFileName) then

                                err.Raise 12345,"CRS-" & DTSGlobalVariables("gAccountType").Value & "-DataUpload DTS Package",  " Extract file not found! Cannot proceed. " & strFeedFileName

                                Main = DTSTaskExecResult_Failure

                                Exit function

                else

                                Set f = fs.GetFile(strFeedFileName)

                                if not f.Size > 0 then

                                                err.Raise 12346,"CRS-" & DTSGlobalVariables("gAccountType").Value & "-DataUpload DTS Package", " Extract file empty! Cannot proceed."

                                                Main = DTSTaskExecResult_Failure

                                                Exit function           

                                end if

                end if

                set fs = nothing

                'to execute the DTS event start values

                Main = DTSTaskExecResult_Success

End Function


What I have tried:

i tried writing in diffrent languages but not getting iam new to this vbscript and vb.net


thanks in advance
Posted
Updated 2-Oct-20 20:15pm
v2
Comments
F-ES Sitecore 3-Oct-20 6:44am    
All it does is check if a file exists and checks the size of the file is greater than 0, and if either of those things aren't true to throw errors. Just google "vb.net check file exists" and "vb.net check file size" for vb.net equivalents.

1 solution

This is not a code conversion service: we are not here to translate code for you.
Even if we did, what you would end up with would not be “good code” in the target language – they are based on very different frameworks, and what makes something work in one language does not always “translate” directly into another.
So what you end up with is very poor code, that is difficult if not impossible to maintain, that can't be upgraded nicely, and that will cause you immense headaches if the original is changed. And it'll be a nightmare to debug if it doesn't work "straight out of the box".
Instead, use the source code as a specification for a new app written in and for the target language / framework and write it from scratch using the original as a "template". You will get a much, much better result that will save you a lot of time in the long run.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900