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
Srinivas M
NA
435
29.2k
How to resume StreamReader to start reading from continue.
Feb 21 2019 1:31 AM
Actually I have an application in that I'm reading Stream data using StreamReader line to line and Inserting into Data Base If any Case Internet Connection Closed or system shutdown then i want to resume Stramreader don't want to read from starting Position of the Stream.
Stream stream = res.GetResponseStream();
using
(StreamReader sr =
new
StreamReader(stream))
{
int
i = 1;
int
j = 0;
string
ss =
""
;
List<
string
> strContent =
new
List<
string
>();
while
(i > j)
{
StringBuilder sb =
new
StringBuilder();
while
(!sr.EndOfStream)
{
string
line = sr.ReadLine();
ss = ss + line;
i++;
if
(line.Equals(
"</record>"
))
{
if
((sr.EndOfStream))
{
}
else
{
ss = ss +
"</records>"
;
}
var mySourceDoc =
new
XmlDocument();
//load the file from the stream
mySourceDoc.LoadXml(ss);
//XmlNode nd = mySourceDoc.DocumentElement.SelectSingleNode("//records");
XmlDocument xmlAPDP =
new
XmlDocument();
xmlAPDP.LoadXml(ss);
XmlNodeReader xmlReader =
new
XmlNodeReader(xmlAPDP);
DataSet dataSet =
new
DataSet();
dataSet.ReadXml(xmlReader);
string
sds = WriteXML(dataSet);
ss =
""
;
ss =
"<?xml version='1.0' encoding='utf-8'?><records xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation ='premium-world-check.xsd'>"
;
j = i;
i = j + 1;
break
;
}
}
if
((sr.EndOfStream))
{
break
;
}
}
}
Reply
Answers (
2
)
Updating textbox values in MVC
Page is not displaying getting error