Solved

readline - vb.net

Posted on 2009-05-07
11
757 Views
Last Modified: 2012-05-06
I really need help with this text file. When there is this weird symbols(char) or whatever we call it on a text file, it reads partial "before a" but it does not returns anything after. This txt file is only part it. The problem is I don't know when there is going to be that char in a txt file.


        Dim sr As New StreamReader(sourcedir) ', System.Text.Encoding.Unicode)

        Dim tmp As String

        tmp = sr.ReadLine
        Me.TextBox1.Text = tmp
0
Comment
Question by:VBdotnet2005
  • 6
  • 5
11 Comments
 

Author Comment

by:VBdotnet2005
ID: 24330387
please see the file
0
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24330447
What file? It is probably a carriage return or a line feed, without the corresponding cr/lf character (they come in pairs on windows). It can also be any other control character that is considered a newline character. It can even be any of the Unicode newline characters (0x80?), which disrupt correct reading.

You can alternatively read it character for character and create your own lines, plus filter those characters out.
0
 

Author Comment

by:VBdotnet2005
ID: 24330491
I uploaded my file. Could you show me in code?
0
 

Author Comment

by:VBdotnet2005
ID: 24330508
I clicked add file and uploaded it.
0
 
LVL 39

Expert Comment

by:abel
ID: 24330527
you say that three times... but I think your file is not allowed. Change the extension to *.txt or something.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 39

Expert Comment

by:abel
ID: 24330532
hmm, you'll have to bear with me for a moment, I have to be off, but somebody else will take over. I'll be back in a few hours though... ;)
0
 

Author Comment

by:VBdotnet2005
ID: 24330569
it is txt file.
0
 
LVL 39

Expert Comment

by:abel
ID: 24331438
Well, I believe you, but something is odd about it and it doesn't upload here, which is strange, because txt files can always be uploaded, I do it all the time and quite often they're actually binary files and it goes all fine.

I'd love to help you, but I do need to have a look at that file. You can also try uploading it somewhere else and send the link here.
0
 

Author Comment

by:VBdotnet2005
ID: 24331692
I figured out out.. I used peek <> -1 method  and system.text.encoding.default.  It worked.
You can close it out now.
0
 

Author Comment

by:VBdotnet2005
ID: 24331696
thanks for your help.
0
 
LVL 39

Expert Comment

by:abel
ID: 24334351
> It worked. You can close it out now.

ah, that's something only you can do.. :)

As it turns out, this is what I suggested in my first comment, #24330447. I'll leave it up to you to award points or to accept your own comment as answer + award points... :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now