Plz help me in converting vb code to vb.net
Function Main()
Dim sMsg as string
sMsg = MoveFile(DTSGlobalVariables("LoadFileName").Value)
if (sMsg) = "" then
Main = DTSTaskExecResult_Success
else
Main = DTSTaskExecResult_Failure
end if
End Function
Function MoveFile(ByVal fileName)
on error resume next
Dim objFSO as string
Dim objFolderDestination as string
Dim objFile as string
Dim newFolderName as string
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolderDestination = objFSO.GetFolder(DTSGlobalVariables("DestinationFolder").Value)
newFolderName = DatePart("m",now) & "-" & Day(now) & "-" & DatePart("yyyy",now) & " " & DatePart("h",now) & "-" & DatePart("n",now) & "-" & DatePart("s",now)
'Check for existance of the fileName passed in
If objFSO.FileExists(fileName) Then
set objFile = objFSO.GetFile(fileName)
'Move the file to the correct directory
If objFSO.FolderExists(objFolderDestination & "\" & newFolderName) Then
objFile.Move(objFolderDestination & "\" & newFolderName & "\")
if Err.Number <> 0 Then
MoveFile = vbCrLf & "could not move file because" & Err.Description & vbCrLf
end if
else
objFSO.CreateFolder(objFolderDestination & "\" & newFolderName)
if Err.Number <> 0 Then
MoveFile = vbCrLf & "could not create folder because" & Err.Description & vbCrLf
end if
objFile.Move(objFolderDestination & "\" & newFolderName & "\" & newFileName)
if Err.Number <> 0 Then
MoveFile = vbCrLf & "could not move file because" & Err.Description & vbCrLf
end if
end if
End If
If Err.Number <> 0 Then
MoveFile = vbCrLf & "File " & fileName & " could not be moved, due to the following error message. " & Err.Description & vbCrLf
Else
MoveFile = ""
End If
End Function