Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 30th, 2009, 02:14 AM
Friend of Wrox
 
Join Date: Jan 2006
Location: Hardwar, Uttranchal, India.
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..
  #2 (permalink)  
Old July 30th, 2009, 03:52 AM
Authorized User
Points: 198, Level: 3
Points: 198, Level: 3 Points: 198, Level: 3 Points: 198, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2008
Location: singapore, singapore, Singapore.
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
  #3 (permalink)  
Old July 30th, 2009, 06:05 AM
Friend of Wrox
 
Join Date: Jan 2006
Location: Hardwar, Uttranchal, India.
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..
  #4 (permalink)  
Old July 30th, 2009, 08:23 AM
Authorized User
Points: 198, Level: 3
Points: 198, Level: 3 Points: 198, Level: 3 Points: 198, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2008
Location: singapore, singapore, Singapore.
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
  #5 (permalink)  
Old July 31st, 2009, 12:12 AM
Friend of Wrox
 
Join Date: Jan 2006
Location: Hardwar, Uttranchal, India.
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..
  #6 (permalink)  
Old July 31st, 2009, 03:01 AM
Registered User
Points: 28, Level: 1
Points: 28, Level: 1 Points: 28, Level: 1 Points: 28, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: Noida, India
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
  #7 (permalink)  
Old July 31st, 2009, 03:19 AM
Friend of Wrox
 
Join Date: Jan 2006
Location: Hardwar, Uttranchal, India.
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..
  #8 (permalink)  
Old August 1st, 2009, 03:51 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
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(); 
}
  #9 (permalink)  
Old August 2nd, 2009, 02:38 AM
Friend of Wrox
 
Join Date: Jan 2006
Location: Hardwar, Uttranchal, India.
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..
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:41 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.