What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » c# Read text file

c# Read text file
Author: Message:
djdannyp
Elite Member
*****

Avatar
Danny <3 Sarah

Posts: 3546
Reputation: 31
37 / Male / Flag
Joined: Mar 2006
O.P. c# Read text file
Okay, here's the situation:

In a C# program I need to read back a text file (from a fixed location) and check that the last character on the second to last line is a 0 and then return true or false.

It sounds so simple (and probably is for someone with semi-decent coding knowledge!), but I'm really struggling with how to accomplish it

Can anyone help me out?

Thanks :)



Also, if anyone knows how to Enable Windows Defender via C# that'd be a MASSIVE help too!

Thanks again :)
[Image: 1ftt0hpk-signature.png]
AutoStatus Script || Facebook Status Script
5207 days, 18 hours, 29 minutes, 6 seconds ago
10-07-2009 02:34 PM
Profile E-Mail PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: c# Read text file
You could use File.ReadAllLines to read the contents of the file to an array of string, each element a line, and access the last char of the second-to-last line using lines[lines.Length-2][lines[lines.Length-2].Length-1] (a bit messy, hope you figure it out :P)
10-07-2009 04:59 PM
Profile PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: c# Read text file
What he said but in code ;)

C# code:
String[] lines = File.ReadAllLines("C:\\thepath.txt");
Char thing = lines[lines.Length - 2][lines[lines.Length - 2].Length - 1];

[Image: 1-0.png]
             
10-07-2009 09:35 PM
Profile PM Web Find Quote Report
djdannyp
Elite Member
*****

Avatar
Danny <3 Sarah

Posts: 3546
Reputation: 31
37 / Male / Flag
Joined: Mar 2006
O.P. RE: c# Read text file
Thanks, yeah, I'd just about managed to put it into code and get it working :)

If anyone can shed any light on the Windows Defender situation that'd also be much appreciated!
[Image: 1ftt0hpk-signature.png]
AutoStatus Script || Facebook Status Script
5207 days, 18 hours, 29 minutes, 6 seconds ago
10-08-2009 12:37 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On