Wrox Programmer Forums
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 30th, 2009, 02:14 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default ReadLine() function.

Hello Friends,


There is a function StreamReader.ReadLine() to read the line from the Files. I want to know that If I have a File which has contents like this:
MyText.txt
This is first line.
This is secont line.
is the third line.


In this file there is a third line which has the 5 spaces in begining of the line but ReadLine function is reading only the TEXT it is not reading SPACES. Is there any way to Read spaces too.


Thanks !!!
__________________
DPK..
 
Old July 30th, 2009, 03:52 AM
Authorized User
 
Join Date: Apr 2008
Posts: 54
Thanks: 0
Thanked 4 Times in 4 Posts
Default

If you are using asp.net with vb.net then try this

My.Computer.FileSystem.ReadAllText(FilePath)

refer here
http://www.vbknowledgebase.com/WebAp...-using-ASP.Net
__________________
Pon Saravanan
VbKnowledgebase.com
 
Old July 30th, 2009, 06:05 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default thanks

thanks pons_saravanan,

But I am using C# asp.net. So you can help me now..

cheers :)
__________________
DPK..
 
Old July 30th, 2009, 08:23 AM
Authorized User
 
Join Date: Apr 2008
Posts: 54
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Quote:
Originally Posted by dpkbahuguna View Post
thanks pons_saravanan,

But I am using C# asp.net. So you can help me now..

cheers :)
let me try my best as i am working more on vb.net

after getting the entire textfile into string using stream reader then search for a line break and find out the lines

Environmetn.NewLine is the constant might be useful for you to split all the ines into a array using something like

textilecontent.split(Environmetn.NewLine )

try and let me know if it works
__________________
Pon Saravanan
VbKnowledgebase.com
 
Old July 31st, 2009, 12:12 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default ReadLine

Hello pons_saravanan,

Thanks for you reply I think u did not get my question my question is not related to the Lines of the file contents..I am asking to read the spaces..

suppose ( * = space )

now what i want to do if there is line like this:
**********This is line.
This line has Ten speces from it's begining. Now I want to show this line at an ASP:Label and in the Label it should show as just it is I mean in label Text it should be start like [**********This is line.] but what is happening now in Label Text is starting like [This is line.]

cheers :)
__________________
DPK..

Last edited by dpkbahuguna; July 31st, 2009 at 12:26 AM..
 
Old July 31st, 2009, 03:01 AM
Registered User
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to shariqmisbahi
Default

Hi DPK...I was able to show spaces...but with a MultiLine TextBox.
See the below code if it helps you.
----------------------------------------

//Code Start
protected void Realwhole()
{
string thefile = Server.MapPath("tic.txt");
StreamReader srdr = default(StreamReader);
srdr = File.OpenText(thefile);
string someString = string.Empty;

while (srdr.Peek() != -1)
{
someString = srdr.ReadToEnd();
TextBox1.Text = someString;
}
srdr.Close();
}
//Code End
 
Old July 31st, 2009, 03:19 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

ya frind there is no probe with txt fld with multiple lines, but problem with the ASP:Label.

in txtbox i m jst doing this and its working fine...

StreamReader SR = new StreamReader(FilePath);
while ((line = SR.ReadLine()) != null)
txtmulti_EditContent.Text += line + '\r';
SR.Close();

but i hv to put in Label too, any idea?

thanks
__________________
DPK..
 
Old August 1st, 2009, 03:51 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Browsers will not render multiple spaces like this. So if you assign

Code:
 
Label1.Text = "          this is a line starting with ten spaces";
the label text will show on the page with no spaces.

To show the spaces, you must convert them to non-breaking HTML spaces.

Code:
Label1.Text = "          this is a line starting with ten spaces".Replace(" ", " ");
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old August 2nd, 2009, 02:38 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

thanks 4 ur reply,
this is right ..I hv got same answer in asp.forums ..


thanks..
__________________
DPK..





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
oTxtStream.ReadLine phungleon Classic ASP Basics 1 April 22nd, 2004 06:56 AM
Readline From Text file and Use as Query phungleon Pro VB Databases 5 February 27th, 2004 10:01 AM
The Readline FUnction Dinesh22 VB.NET 2002/2003 Basics 2 January 29th, 2004 10:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.