Got in a difficult situation of storing and retrieving TextReader in
Cache, but found no such post yet.
Tried to store a textreader into Cache object in a similar way
illustrated in .NET's SDK doc ("Retrieving Values of Cached Items"):
' -----------------------------
...
Dim CPCache As textreader = CType(Cache("CP "), textreader)
If CPCache Is Nothing Then
...
Dim txtrd As TextReader = ... ' get something to fill the txtrd.
Cache.Insert("C P", txtrd)
' display txtrd's content on the page
divTag.InnerTex t = "New!!! " & txtrd.ReadtoEnd
Else
divTag.InnerTex t = "Cache exists! " & CPCache.ReadtoE nd
End If
' -----------------------------
Web page displayed the txtrd content when it ran the first time as:
New!!! ..... (content of txtrd, all normal char as expected)
Then showed:
Cache exists!
It's verified the length of CPCache's content is zero in Cache. But no
error returned.
However, replacing "txtrd" (TextReader) with "str" (string) and
appropriate methods, content of "str" is shown correctly following
"Cache exists! " on the page.
Does anyone have any experience of TextReader in Cache?
Thanks. 3 1459
Hello
I think you need to rewind the text reader every time you use it. Anyways I
I don't understand why do you store the text reader in cache, because in
this case you are only storing a pointer to a stream. Caching the content
you read from the textreader may be a better way.
Best regards
Sherif
"Chan" <hi*****@yahoo. com> wrote in message
news:fe******** *************** ***@posting.goo gle.com... Got in a difficult situation of storing and retrieving TextReader in Cache, but found no such post yet.
Tried to store a textreader into Cache object in a similar way illustrated in .NET's SDK doc ("Retrieving Values of Cached Items"): ' ----------------------------- ... Dim CPCache As textreader = CType(Cache("CP "), textreader) If CPCache Is Nothing Then ... Dim txtrd As TextReader = ... ' get something to fill the txtrd. Cache.Insert("C P", txtrd) ' display txtrd's content on the page divTag.InnerTex t = "New!!! " & txtrd.ReadtoEnd Else divTag.InnerTex t = "Cache exists! " & CPCache.ReadtoE nd End If ' -----------------------------
Web page displayed the txtrd content when it ran the first time as:
New!!! ..... (content of txtrd, all normal char as expected)
Then showed:
Cache exists!
It's verified the length of CPCache's content is zero in Cache. But no error returned.
However, replacing "txtrd" (TextReader) with "str" (string) and appropriate methods, content of "str" is shown correctly following "Cache exists! " on the page.
Does anyone have any experience of TextReader in Cache?
Thanks.
"Chan" <hi*****@yahoo. com> wrote in message
news:fe******** *************** ***@posting.goo gle.com... Got in a difficult situation of storing and retrieving TextReader in Cache, but found no such post yet.
Tried to store a textreader into Cache object in a similar way illustrated in .NET's SDK doc ("Retrieving Values of Cached Items"): ' ----------------------------- ... Dim CPCache As textreader = CType(Cache("CP "), textreader) If CPCache Is Nothing Then ... Dim txtrd As TextReader = ... ' get something to fill the txtrd. Cache.Insert("C P", txtrd) ' display txtrd's content on the page divTag.InnerTex t = "New!!! " & txtrd.ReadtoEnd Else divTag.InnerTex t = "Cache exists! " & CPCache.ReadtoE nd End If ' -----------------------------
Web page displayed the txtrd content when it ran the first time as:
New!!! ..... (content of txtrd, all normal char as expected)
Then showed:
Cache exists!
Once you've read to the end of your TextReader, it's done. You're at the
end. That's all there is.
David
In .Net document, "DataReader " is described as "forward-only", but
"TextReader " isn't.
Is it true that everything named "Reader" are forward-only like
"DataReader "?
Is there any non-forward-only class corresponding to "TextReader "?
Thanks! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steve Binney |
last post by:
My code makes synchronous HttpWebRequest and HttpRebResponse calls. In VS
2003, I am getting memory leaks and event handle leaks. I am closing all
streams and using "using"statements. I have used .Net memory profiler from
Sci Tech to analyze the leaks and they are coming from inside HttpWebRequest
and HttpRebResponse. When I run my code on VS2005, I do not get any leaks.
Is this problem fixed in .Net 1.1 SP1? I may not be able to wait...
|
by: |
last post by:
I am rewriting a C++ application in C#. This file has a combination of Text
and Binary data.
I used CFile before to read the text. If I hit a certain string that
denotes the following data is binary, I used the current position in the
file and another stream to read to the binary data.
All text data is ended with a carriage return / line feed while the binary
is actually an image file listed byte by byte. Preceding the binary data...
|
by: Colin Green |
last post by:
Hi I wonder if anyone has any ideas about this...
I am dumping the contents of an XmlDocument into a RichTextBox so the
user can see the raw XML. I use a line of code something like this to
lado the Xml text into the textbox:
richTextBox.Text = xmlDoc.ToString();
I recon this technique is inefficient with large xml documents.
|
by: Fernando Chilvarguer |
last post by:
Hi,
I'm retriving data from a database and storing it on the Cache Object using
the following code:
HttpContext.Current.Cache.Insert(
cacheItemKey,
contentDS, //THE DATASET WITH MY DATA
null,
DateTime.Now.AddSeconds(600),
|
by: Bryan Dickerson |
last post by:
StreamReader says it is designed to read a stream of characters
StringReader says it is designed to read a string
TextReader says it is designed to read a sequential list of characters.
I hate to sound like a VB6 grump, but aren't we splitting hairs?? What's
the difference?
--
TFWBWY...A
| |
by: trint |
last post by:
When testing locally with:
TextReader tr = new StreamReader(@"C:\gcc.set");
Now that I have uploaded this to the server on the net,
that locations permissions are denied.
How can I change this to work with StreamReader on the Web
or do I have to use a different function?
Any help is appreciated.
Thanks,
Trint
|
by: Rene |
last post by:
Hi,
I decided to take a closer look at the TextWriter and TextReader abstract
classes just for fun.
While poking around, I noticed that the TextWriter class includes an
'Encoding' property in its definition. To me, this sounds very logical
because the TextWriter is all about writing text and sooner or later you
will need to use a type of encoding that specifies how to write (persist)
the text.
|
by: BizWorld |
last post by:
I am trying to cache a full DROP Down that can have lot of values. so
i have 500 site users hitting a page in a second. i need to cache some
controls that does not change quite often during the day. i am trying
to test HTTRuntime.Cache object. in debug mode i can see the values on
server side after i get the drop down from the cache but some how it
does not show the values on generated html page. any idea what i am
missing???
If...
|
by: Tony Johansson |
last post by:
Hello!
I just wonder in this specific case is it any advantage to use a
TextReader a reference to a StreamReader ?
Try
{
TextReader tr = new StreamReader(locationTextBox.Text);
Try
{
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |