473,382 Members | 1,752 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.

StreamReader

This object works great with "files".

but I have a Virtual web Site under my main site that points to my file share.
Since this is secure, I'd like to open the file via its url.

I tried this but .net failed. Said URI formats are not supported!

string sFile = "https://myServer/Reports//12345/myfile.asp";
StreamReader oTextFile = new StreamReader(sFile);

Is it possible to use the StreamReader object on url files?

Thanks

Mike
Nov 15 '05 #1
7 7186


Mike wrote:
This object works great with "files".

but I have a Virtual web Site under my main site that points to my file share.
Since this is secure, I'd like to open the file via its url.

I tried this but .net failed. Said URI formats are not supported!

string sFile = "https://myServer/Reports//12345/myfile.asp";
StreamReader oTextFile = new StreamReader(sFile);

Is it possible to use the StreamReader object on url files?

No, there are no "url files".
If you want to read from a HTTP or HTTPS URL then use
WebRequest.Create(@"https://example.com/dir/page.asp")
For simple things there is also WebClient

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 15 '05 #2
Martin

Do you have an example of how I can use WebRequest in conjunction with StreamReader to open the URI

I'm struggling here
Nov 15 '05 #3


Mike wrote:
Do you have an example of how I can use WebRequest in conjunction with StreamReader to open the URI?


http://samples.gotdotnet.com/quickst...hSSL.cs&font=3

If you are new to .NET then consider installing the .NET SDK with the
quickstart tutorial on your development machine as then you have all
such examples there to look at

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 15 '05 #4
Mike,
Did you check the sample under WebReponse.GetResponseStream? (you get the
WebResponse from WebRequest.GetResponse).

http://msdn.microsoft.com/library/de...treamTopic.asp

Alternatively did you check the sample under WebClient.OpenRead?

http://msdn.microsoft.com/library/de...nReadTopic.asp

Both return a Stream objects, that you can then pass to the constructor of
the StreamReader class.

Hope this helps
Jay

"Mike" <an*******@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
Martin:

Do you have an example of how I can use WebRequest in conjunction with StreamReader to open the URI?
I'm struggling here.

Nov 15 '05 #5
Jay

Many thanks for the tip. In looking more closely at this object..

BTW... can you explain to me what an abstract class is and what it is such?
Nov 15 '05 #6


Mike wrote:
BTW... can you explain to me what an abstract class is and what it is such?


Does the C# documentation
http://msdn.microsoft.com/library/de...rfAbstract.asp
not help to explain what an abstract class is?
--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 15 '05 #7
Thanks alot Martin for the URL.

Tom

----- Martin Honnen wrote: -----

Mike wrote:
BTW... can you explain to me what an abstract class is and what it is such?


Does the C# documentation
http://msdn.microsoft.com/library/de...rfAbstract.asp
not help to explain what an abstract class is?
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 15 '05 #8

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

Similar topics

9
by: oafyuf | last post by:
Hi, I'm having performanbce issues with StreamReader and was wondering what I could do to improve it... The following takes around 3 seconds to process! The content of the response is: ...
5
by: Anders Olsson | last post by:
I need to create a StreamReader which starts from the position of an existing StreamReader. This way, the second StreamReader can read lines "ahead" in an own loop, and then I can go back to the...
11
by: Tiger | last post by:
We can use seek() in the FileStream class,as we know. But I found that seek() is not work correctly in StreamReader. Who can tell me how to use seek() correctly in StreamReader? thanks a lot! I...
2
by: Keith Kingsley | last post by:
I'm using a StreamReader to read in several lines from an ASCII file. I'd like to know the StreamReader's "true" position-- that is, the number of bytes into the file that the StreamReader has...
3
by: Arno | last post by:
Hi, I'm using TcpClient for communication between two PC running a small piece of software. The protocol used has been designed internally and is HTTP similar (command line, headers, body). A...
3
by: Mika M | last post by:
Hello! I'm reading text file line by line using the StreamReader like code below shows. Reading is working fine, but if readed line contains Scandinavian letters like äÄöÖ then those letters are...
3
by: Arpan | last post by:
A file can be read using only the StreamReader object like this: Dim sReader As StreamReader sReader = New StreamReader(Server.MapPath("File1.txt")) While(sReader.Peek -1)...
1
by: garyusenet | last post by:
>From MSDN I'm trying to learn more about streamreader. I'm working my way down the MSDN definition. The first entry is the Public Constructor StreamReader. I'm fairly happy I have a basic grasp on...
1
by: Sladan | last post by:
Im trying to read a xml-file with a StreamReader. For the moment I'm using the following code. streamReader = new StreamReader(stream, System.Text.Encoding.Default); string feedData =...
0
by: rajana | last post by:
Dear All, We have Ansi file with german characters (Ä / Ø) , We are using Streamreader to read the contents of the file. But Readline() not able to read the German characters. We tried all...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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.