Environment:
Running this code on my PC via VS 2005
.Net version 2.0.50727 on the server (shown in IIS)
Code is in ASP.NET 2.0 and is a VB.NET Console application
Problem & Info:
I am simply trying to do a couple If statement on comparing the value in my array but not sure how to form it correctly
The problem is here, I just do not know how to form this check:
ElseIf Parts(2).Substring(1, 1) = "MT" Then
ElseIf Parts(2).Substring(1, 1) <> "MT" And Parts(2).Substring(1, 1) <> "AR" Then
I’m simply just not forming the above portions correctly and not sure how.
More of the code (in case you want to see what is before it):
Public Sub ProcessFiles(ByVal sIncomingfile As String, ByVal sOutputDirectory As String)
If sIncomingfile <> "" And sOutputDirectory <> "" Then
Dim f As New Security.Permissions.FileIOPermission(Security.Permissions.PermissionState.None)
f.AllLocalFiles = Security.Permissions.FileIOPermissionAccess.Read
Dim file As New IO.FileInfo(sIncomingfile)
Dim filefs As IO.FileStream = Nothing
Dim reader As New IO.StreamReader(filefs)
Dim counter As Integer = 0
Dim CurrentFS As IO.FileStream
Dim CurrentWriter As IO.StreamWriter
Dim extension As String = IO.Path.GetExtension(file.FullName)
If file.Exists Then
Try
filefs = New IO.FileStream(file.FullName, IO.FileMode.Open) 'Place: 1
Catch ex As Exception
SendEmail("Incoming Filename Invalid or not found", "Place: 1")
End
End Try
End If
If extension = ".mnt" Then
While Not reader.Peek < 0
Dim Line As String = reader.ReadLine
If IsNumeric(Line.Substring(0, 1)) Then
Dim Parts() As String = Line.Split(" "c) ' split row into parts
If Parts(0).Length = 8 Then ' if first part is 8 then know we hit another header so cut and then write to file
' First call function to insert the columns into table
InsertLineTable(Parts, "Header")
counter += 1
If Not CurrentWriter Is Nothing Then CurrentWriter.Flush() : CurrentWriter.Close()
CurrentFS = New IO.FileStream(IO.Path.Combine(IO.Path.GetDirectoryName(sOutputDirectory), Line.Substring(59, 4) & "[" & counter.ToString & "]" & Now.ToString("MM-dd-yyyy") & IO.Path.GetExtension(file.FullName)), IO.FileMode.Create)
CurrentWriter = New IO.StreamWriter(CurrentFS)
ElseIf Parts(2).Substring(1, 1) = "MT" Then
InsertLineTable(Parts, "mnt")
ElseIf Parts(2).Substring(1, 1) <> "MT" And Parts(2).Substring(1, 1) <> "AR" Then
InsertLineTable(Parts, "pmt")
End If
…
Desired Resolution:
How to correct the syntax or a better way to check that value in the Line

How to check array string
audigger
Here is the doc for substring
Public Function Substring(ByVal startIndex As Integer, ByVal length As Integer) As String
Member of: System.String
Summary:
Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.
Parameters:
startIndex: The index of the start of the substring.
length: The number of characters in the substring.
Return Values:
A System.String equivalent to the substring of length length that begins at startIndex in this instance, or System.String.Empty if startIndex is equal to the length of this instance and length is zero.
Exceptions:
System.ArgumentOutOfRangeException: startIndex plus length indicates a position not within this instance.-or- startIndex or length is less than zero.
TBurrowsNZ
actually the problem ended being somewhere else. It was referring to this
InsertLineTable(Parts,
"pmt")which should have been
InsertLineTable(Parts.ToString,
"pmt")John W Powell
Parts(2) and how I'm referencing that array value.