473,382 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

The difference between these 2 techniques in open xml file ?

Hi there,

I am just curious, is there any difference between these 2 techniques used
as below:

1.

FileStream fs = new FileStream(@"C:\hello.xml", FileMode.Open);
XmlTextReader xmlreader = new XmlTextReader(fs);

2.

XmlTextReader xmlreader = new XmlTextReader(@"C:\hello.xml");

Any help?

Cheers.
--
Regards,
Chua Wen Ching
Visit us at http://www.necoders.com
Nov 16 '05 #1
4 2292
HI Chua
First to say , FileStreams buffer input and output which help
improve performance. Also what you can with file streams in .net it gives
you the built in asynchronous call option as you can issue an
asynchronous read or asynchronous write on the file using the beginRead
and beginWrite method .
In your case you can use that if you know that loading the file to the
reader would take a while and you don't want the UI , forexample, to block
while the lading of the reader, what can be caused by the statement
XmlTextReader xmlreader = new XmlTextReader(@"C:\hello.xml"); and would not
happen if you are to use a begin read instead
One other thing is that streams allow random access for sure to the file
with the seek method ( thought most files allow that , you will not be sure
however ).
Hope this helps
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2
fundementally the second uses the first under the covers.

However, the second demonstrates that you can hook an XmlTextReader on to any stream not just a file stream - so a network stream for example or a memory stream

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Hi there,

I am just curious, is there any difference between these 2 techniques used
as below:

1.

FileStream fs = new FileStream(@"C:\hello.xml", FileMode.Open);
XmlTextReader xmlreader = new XmlTextReader(fs);

2.

XmlTextReader xmlreader = new XmlTextReader(@"C:\hello.xml");

Any help?

Cheers.
--
Regards,
Chua Wen Ching
Visit us at http://www.necoders.com

Nov 16 '05 #3
Thanks Richard for the neat explanations :)

"Richard Blewett [DevelopMentor]" wrote:
fundementally the second uses the first under the covers.

However, the second demonstrates that you can hook an XmlTextReader on to any stream not just a file stream - so a network stream for example or a memory stream

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Hi there,

I am just curious, is there any difference between these 2 techniques used
as below:

1.

FileStream fs = new FileStream(@"C:\hello.xml", FileMode.Open);
XmlTextReader xmlreader = new XmlTextReader(fs);

2.

XmlTextReader xmlreader = new XmlTextReader(@"C:\hello.xml");

Any help?

Cheers.
--
Regards,
Chua Wen Ching
Visit us at http://www.necoders.com

Nov 16 '05 #4
Hi Mohamoss,

Thanks for the info :)

Cheers.

"Mohamoss" wrote:
HI Chua
First to say , FileStreams buffer input and output which help
improve performance. Also what you can with file streams in .net it gives
you the built in asynchronous call option as you can issue an
asynchronous read or asynchronous write on the file using the beginRead
and beginWrite method .
In your case you can use that if you know that loading the file to the
reader would take a while and you don't want the UI , forexample, to block
while the lading of the reader, what can be caused by the statement
XmlTextReader xmlreader = new XmlTextReader(@"C:\hello.xml"); and would not
happen if you are to use a begin read instead
One other thing is that streams allow random access for sure to the file
with the seek method ( thought most files allow that , you will not be sure
however ).
Hope this helps
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jonatan | last post by:
Hi all, I'm trying to upload files doing something like gmail. I almost got it but I have a problem when I post the form. Basicaly, I am doing the following. When the user presses the link...
3
by: Murasama | last post by:
Hi there, Im trying a simple file IO operation in Visual Studio .NET 2003 and it can't seem to open the file. If I run the exe in the debug directory it works fine but if I click the start...
6
by: Charles Morrall | last post by:
I have no experience with DB2 as such, but I've been tasked with configuring backup of a server running DB2 v8 on Windows Server 2003. I do have some experience with backups in general though. The...
3
by: GrantS | last post by:
I am needing to permit users to select files using the 'Open file' common dialog box. The format of the names of the files are along the names of: GB00((&X.001.jpg I am not able to show these...
2
by: nissiml | last post by:
hi, i'm trying to open a asp.net web page that list files from a Windows application like winword and select a file from it . what do i have to do to make it happen, is it simple ? Thanks in...
2
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for...
1
by: hzgt9b | last post by:
I am writing a VB.NET (VS2003) program that runs off a CD. One of the tasks that this program must perform is to run some exe's (for example windows updates and virus signature & engine updates)...
2
by: agphoto | last post by:
There is big or problem in open file in read and write mode.. $file = "data.txt"; $fp = fopen($file,"w+"); $line = fgets($fp,"120"); // i need only 1st line to read and upto 120 bytes echo...
4
by: DyslexicAnaboko | last post by:
Hello, I have a module that is part of larger project that is giving me trouble, so I setup an example. Brief ===== I simply want to open a text file and make the contents avaliable...
5
by: Ryan Liu | last post by:
Hi, Both way works, I'd just ask some experts which way is better? My application creates a log file daily. Now each time when I write a log, I will open the file and append to the end....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.