Question Read Last Record of file

sonia.sardana

Active member
Joined
Jan 25, 2009
Messages
35
Programming Experience
Beginner
I want to read just the last record of file....I m able to read the whole file.

Secondly I want to know that in VB.Net we have ubound to get the upper bound of the array..What is the equivalent in ASP.net?


VB.NET:
protected void Page_Load(object sender, EventArgs e)
    {
       
        string sProdID;
        string sID="P000";
        string sLastLine;
         string[] sArr;

        string sPath = Server.MapPath("~/") ;
        string sFileName = sPath + "Products.txt";
        if (File.Exists(sFileName.Trim()) == true)
        {
            sArr = System.IO.File.ReadAllLines(sFileName);
      }
           

    }
Above code read the File...

Suppose mine file contains-
VB.NET:
1^^^^Desc1^^^^50.00^^^^12
2^^^^Desc2^^^^50.00^^^^12
3^^^^Desc3^^^^50.00^^^^12
4^^^^Desc4^^^^50.00^^^^12
5^^^^Desc5^^^^50.00^^^^12
6^^^^Desc6^^^^50.00^^^^12
7^^^^Desc7^^^^50.00^^^^12
8^^^^Desc8^^^^50.00^^^^12
9^^^^Desc9^^^^50.00^^^^12
10^^^^Desc10^^^^50.00^^^^12
 
This is a VB.NET forum, please don't post C# code.

VB.NET:
Dim fileLines As New List(Of String)
fileLines.AddRange(File.ReadAllLines(sFileName))
Dim lastLine As String = fileLines.Count - 1

Secondly I want to know that in VB.Net we have ubound to get the upper bound of the array..What is the equivalent in ASP.net?

myArray.Length - 1
 
Back
Top