Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. read file from bottom

read file from bottom

Scheduled Pinned Locked Moved C#
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vineeshV
    wrote on last edited by
    #1

    I need to read a file from the bottom is it possible in c language ? The exact requirement is suppose having a file like ======================================== hi how are you exit 1 then you exit 1 and i can make this exit 0 =========================================== I need to read the file from bottom to search the last exit 1 and print the lines above it the output will be then you Can anybody help me ??

    vineesh

    C 1 Reply Last reply
    0
    • V vineeshV

      I need to read a file from the bottom is it possible in c language ? The exact requirement is suppose having a file like ======================================== hi how are you exit 1 then you exit 1 and i can make this exit 0 =========================================== I need to read the file from bottom to search the last exit 1 and print the lines above it the output will be then you Can anybody help me ??

      vineesh

      C Offline
      C Offline
      C1AllenS
      wrote on last edited by
      #2

      Hello Vineesh, Trh using the given code snippet. You need to import the namespace System.IO. using System.IO; BEGIN CODE StreamReader sr = new StreamReader("C:\\Test.txt"); String str; str = sr.ReadToEnd(); int index= str.LastIndexOf("exit 1"); TextBox1.Text=str.Substring(0,index); END CODE I hope this will meet your requirement. Regards, Allen

      Allen Smith ComponentOne LLC www.componentone.com

      A V 2 Replies Last reply
      0
      • C C1AllenS

        Hello Vineesh, Trh using the given code snippet. You need to import the namespace System.IO. using System.IO; BEGIN CODE StreamReader sr = new StreamReader("C:\\Test.txt"); String str; str = sr.ReadToEnd(); int index= str.LastIndexOf("exit 1"); TextBox1.Text=str.Substring(0,index); END CODE I hope this will meet your requirement. Regards, Allen

        Allen Smith ComponentOne LLC www.componentone.com

        A Offline
        A Offline
        Atif Ali Bhatti
        wrote on last edited by
        #3

        hi, File.ReadAllBytes returns a byte array which can be then used the way you want to play with it. Regards. Atif Ali Bhatti.

        1 Reply Last reply
        0
        • C C1AllenS

          Hello Vineesh, Trh using the given code snippet. You need to import the namespace System.IO. using System.IO; BEGIN CODE StreamReader sr = new StreamReader("C:\\Test.txt"); String str; str = sr.ReadToEnd(); int index= str.LastIndexOf("exit 1"); TextBox1.Text=str.Substring(0,index); END CODE I hope this will meet your requirement. Regards, Allen

          Allen Smith ComponentOne LLC www.componentone.com

          V Offline
          V Offline
          vineeshV
          wrote on last edited by
          #4

          Thanks .. It works

          vineesh

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups