|
|
#1 |
|
Member
Join Date: Jun 03
Location: Georgia
Posts: 32
![]() |
[2005] Search a string for ControlChars.CrLf
I am passing in a string using a streamreader. I am trying to find if a line uses CrLf, Cr, or LF. I have tried using an Instr but it always returns 0. What am I doing wrong? Should I be using something else?
VB Code:
Thanks Shannon
__________________
My Webpage |
|
|
|
|
|
#2 |
|
.NUT
Join Date: May 05
Location: Sydney, Australia
Posts: 60,536
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [2005] Search a string for ControlChars.CrLf
CrLf is a Windows line break, which consists of a carriage return and a line feed. If your string doesn't contain that combination then it can't be found. If your string only contains line feeds then you need to search for line feeds only. Line feeds on their own are used as line breaks on most other OSes, so Windows will normally treat them as line breaks too. Try this:
VB Code:
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs MSDN "How Do I?" Videos: VB | C# VBForums Database Development FAQ My CodeBank Submissions: VB | C# (ForumAccount has translated some of my VB submissions to C#) My Blog: Defining and Raising Custom Events | Manipulating GDI+ Drawings | Using Parameters in ADO.NET |
|
|
|
|
|
#3 |
|
Member
Join Date: Jun 03
Location: Georgia
Posts: 32
![]() |
Re: [2005] Search a string for ControlChars.CrLf
Thanks for the quick reply. You code worked great. My problem was I was using the sr.readline instread of sr.readtoend. We get fixed width files in from clients that are generated from a mainframe and they say they are CRLF and alot of times they use LF and our ETL tool needs to know what type so I trying to write an app that will check and put the correct line terminator in. Again, thanks for your help.
Shannon
__________________
My Webpage |
|
|
|
|
|
#4 |
|
Fanatic Member
Join Date: Jul 05
Location: Colorado
Posts: 592
![]() |
Re: [2005] Search a string for ControlChars.CrLf
ReadLine() only reads the current line of the stream while ReadToEnd() reads the whole stream.
__________________
C# - .NET 1.1 / .NET 2.0 "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something." _____________________ Regular Expressions Library Connection String API Functions Database FAQ & Tutorial |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|