Hello:
I am trying to read all the files from any pre-defined folder (C:\TEMP\A1) and its all the Sub-Directories
(C:\TEMP\A1\A21; C:\TEMP\A1\A21\A31; C:\TEMP\A1\A22; C:\TEMP\A1\A22\A32 ) copying those filtered Extensions as defined in
Dim sExtensionValue As String = "TXT,DBF"
to another location (J:\TEMP). The copying procedure is copying to Folder to Folder and its sub-folder to sub-folder.
However, if I use Variable to create the IF..Else..Endif, then it does not work. But if I take the Final value ot the Variable and put into like
Dim sTempString As String = ""
Dim sExtensionValue As String = "txt,dbf"
Dim strFilename As String = "My_Doc.DOCX"
Dim ss As String = ""
If " " & sTempString & " " Then
' In this routine, it comes here which is wrong while I am using Variables to Create the value of sTempString
MsgBox("Here I Am, Which Is Wrong")
Else
MsgBox("Here I Am, Which Is Right")
End If
Where
sTempString =UCase(Mid("My_Doc.DOCX", InStrRev("My_Doc.DOCX", ".", Len("My_Doc.DOCX")) + 1, 3)) = "TXT" Or _
UCase(Mid("My_Doc.DOCX", InStrRev("My_Doc.DOCX", ".", Len("My_Doc.DOCX")) + 1, 3)) = "DBF"
Again, I am using the value of sTempString and puto the following fashion, then it works
If UCase(Mid("My_Doc.DOCX", InStrRev("My_Doc.DOCX", ".", Len("My_Doc.DOCX")) + 1, 3)) = "TXT" Or _
UCase(Mid("My_Doc.DOCX", InStrRev("My_Doc.DOCX", ".", Len("My_Doc.DOCX")) + 1, 3)) = "DBF" Then
MsgBox("Here I Am, Which Is Wrong")
Else
' In this routine, it comes here which is right
MsgBox("Here I Am, Which Is Right")
End If
My assumption is to update somewhere into the following code in such a manner that the value of sTempString would work in If...Else..Endif
Dim aFileExtension() As String = Split(sExtensionValue, Chr(44))
For X = LBound(aFileExtension) To UBound(aFileExtension) - 1
ss = UCase(aFileExtension(X).ToString)
sTempString = sTempString & "UCase(Mid(" & Chr(34) & strFilename & Chr(34) & ",InStrRev(" & Chr(34) & strFilename _
& Chr(34) & "," & Chr(34) & Chr(46) & Chr(34) & ",Len(" & Chr(34) & strFilename _
& Chr(34) & "))" & Chr(43) & Chr(49) & "," & Chr(51) & "))=" & Chr(34) & ss & Chr(34) & " Or "
Next
ss = UCase(aFileExtension(X).ToString)
sTempString = sTempString & "UCase(Mid(" & Chr(34) & strFilename & Chr(34) & ",InStrRev(" & Chr(34) & strFilename _
& Chr(34) & "," & Chr(34) & Chr(46) & Chr(34) & ",Len(" & Chr(34) & strFilename _
& Chr(34) & "))" & Chr(43) & Chr(49) & "," & Chr(51) & "))=" & Chr(34) & ss & Chr(34)
Next
I need to get through this problem.
Thanks for your time and effort for anticipation.
Regards.
Firstlast775, if this helps please login to Mark As Answer. | Alert Moderator