TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
kris
NA
26
20.2k
Not able to read special character “£” using Streamreader in
Mar 28 2014 11:38 AM
I am trying to read a character (
£
) from a text file, using the following code:
public
static
List
<string>
ReadAllLines
(
string
path
,
bool discardEmptyLines
,
bool doTrim
)
{
var
retVal
=
new
List
<string>
();
if
(
string
.
IsNullOrEmpty
(
path
)
||
!
File
.
Exists
(
path
))
{
Comm
.
File
.
Log
.
LogError
(
"ReadAllLines"
,
string
.
Format
(
"Could not load file: {0}"
,
path
));
return
retVal
;
}
//StreamReader sr = null;
StreamReader
sr
=
new
StreamReader
(
path
,
Encoding
.
Default
));
try
{
sr
=
File
.
OpenText
(
path
);
while
(
sr
.
Peek
()
>=
0
)
{
var
line
=
sr
.
ReadLine
();
if
(
discardEmptyLines
&&
(
line
==
null
||
string
.
IsNullOrEmpty
(
line
.
Trim
())))
{
continue
;
}
if
(
line
!=
null
)
{
retVal
.
Add
(
doTrim
?
line
.
Trim
()
:
line
);
}
}
}
catch
(
Exception
ex
)
{
Comm
.
File
.
Log
.
LogGeneralException
(
"ReadAllLines"
,
ex
);
}
finally
{
if
(
sr
!=
null
)
{
sr
.
Close
();
}
}
But my code is not correctly reading £, It is reading the character as ? please guide me what needs to be done to read the special character.
And My text file is::
108|25|50001408|4|6.95|£
108|25|50001392|4|5.23|£
108|25|50001385|3|5.29|£
108|25|50001378|3|14.25|£
Thanks in advance.
Reply
Answers (
2
)
how to send sms using way2sms and fullonsms in asp.net
crystal report add multiple coloums