ASP.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a ASP.NET Expert!

Join 307,139 ASP.NET Programmers for FREE! Get instant access to thousands of ASP.NET experts, tutorials, code snippets, and more! There are 1,793 people online right now. Registration is fast and FREE... Join Now!




Read Last Record of file

 

Read Last Record of file

sonia.sardana

26 Jun, 2009 - 09:25 AM
Post #1

D.I.C Head
**

Joined: 1 Jun, 2008
Posts: 132



Thanked: 5 times
My Contributions
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?


CODE

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-
CODE

1^happy.gif^Desc1^happy.gif^50.00^happy.gif^12
2^happy.gif^Desc2^happy.gif^50.00^happy.gif^12
3^happy.gif^Desc3^happy.gif^50.00^happy.gif^12
4^happy.gif^Desc4^happy.gif^50.00^happy.gif^12
5^happy.gif^Desc5^happy.gif^50.00^happy.gif^12
6^happy.gif^Desc6^happy.gif^50.00^happy.gif^12
7^happy.gif^Desc7^happy.gif^50.00^happy.gif^12
8^happy.gif^Desc8^happy.gif^50.00^happy.gif^12
9^happy.gif^Desc9^happy.gif^50.00^happy.gif^12
10^happy.gif^Desc10^happy.gif^50.00^happy.gif^12



User is offlineProfile CardPM
+Quote Post


kmangold

RE: Read Last Record Of File

26 Jun, 2009 - 09:28 AM
Post #2

D.I.C Head
Group Icon

Joined: 24 Jun, 2009
Posts: 166



Thanked: 7 times
Dream Kudos: 75
My Contributions
CODE

sArray[sArray.Length - 1]

User is offlineProfile CardPM
+Quote Post

eclipsed4utoo

RE: Read Last Record Of File

26 Jun, 2009 - 11:23 AM
Post #3

Not Your Ordinary Programmer
Group Icon

Joined: 21 Mar, 2008
Posts: 1,846



Thanked: 205 times
Dream Kudos: 500
Expert In: .NET

My Contributions
ASP.Net is not a language. ASP.Net applications can be written in both C# and VB.Net. So if you use UBound to get the upper bound of an array in windows, then you would use the same if you are writing an ASP.Net application in VB.Net.
User is offlineProfile CardPM
+Quote Post

sonia.sardana

RE: Read Last Record Of File

28 Jun, 2009 - 08:35 AM
Post #4

D.I.C Head
**

Joined: 1 Jun, 2008
Posts: 132



Thanked: 5 times
My Contributions
thx......
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 03:25PM

Live ASP.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

ASP.NET Tutorials

Reference Sheets

ASP.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month