Hello, I am a bit of a newbie to programming but I know my way around pretty well. I have been getting an error when I debug my program and it says, "Index Was Outside The Bounds of the Array".
Here is my code:
It highlights lblFilePath1.Text when it gives me the error message. I'm not quite sure what to do, so I came here for help.
Thanks, robblie_bob
Here is my code:
Code:
If lblFilePath1.Text IsNot "Label2" Then
'Adds text to "FileName" file
Dim fileContents As String = System.IO.File.ReadAllText("C:/Server/FilePath.txt")
Dim lines() As String
fileContents = fileContents.Replace(ControlChars.CrLf, ControlChars.Lf)
lines = fileContents.Split(New Char() {ControlChars.Lf, ControlChars.Cr})
lines(1) = lblFilePath1.Text
System.IO.File.WriteAllText("C:/Server/FilePath.txt", String.Join(ControlChars.NewLine, lines))Thanks, robblie_bob