StreamReader Object

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This object wokrs great with file and file shares.

But I have a virtual web site created that points to my file share where my files are located. Since this virtual web site is protected, I'd like to use the web site's file instead of the file share.

Is it possible to open a file (StreamReader) via the files url?

This failed.

sFile = "//https://myServer/Reports/12345/12345.asp";

StreamReader oTextFile = new StreamReader(sFile);


Thanks
Mike
 
This object wokrs great with file and file shares.

But I have a virtual web site created that points to my file share where my files are located. Since this virtual web site is protected, I'd like to use the web site's file instead of the file share.

Is it possible to open a file (StreamReader) via the files url?

This failed.

sFile = "//https://myServer/Reports/12345/12345.asp";

StreamReader oTextFile = new StreamReader(sFile);

You can use WebRequest to make a request on a URL. The returned
WebResponse object has a "GetResponseStream()" method which will return
a Stream instance (which can be passed to a StreamReader constructor).
 
Patrick:

Actually, the WebRequest object contains a GetRequestSteam() that returns a stream.

So when I used this, I got this error

Cannot send a content-body with this verb-type

Can you advise futher.

here is my code:

Uri myUri =new Uri("http://mySever/FRpt/12896/1620013.asp");
// Create a new request to the above mentioned URL.
WebRequest myWebRequest= WebRequest.Create(myUri);
Stream myStream = myWebRequest.GetRequestStream(); //fails here

Mike


----- Patrick Steele [MVP] wrote: -----

This object wokrs great with file and file shares.

You can use WebRequest to make a request on a URL. The returned
WebResponse object has a "GetResponseStream()" method which will return
a Stream instance (which can be passed to a StreamReader constructor).
 
Patrick:

Actually, the WebRequest object contains a GetRequestSteam() that returns a stream.

Yes, but you don't want to manipulate the *request*, you want the
*response* from the request. See the docs for the WebRequest.Create()
method -- it shows a sample of getting a WebResponse.
 
Got it now but now I get this error

The underlying connection was closed: Could not establish trust relationship with remote server

Any ideas on what to look for

BTW... Thanks for all your advis

Mik

----- Patrick Steele [MVP] wrote: ----


Yes, but you don't want to manipulate the *request*, you want the
*response* from the request. See the docs for the WebRequest.Create()
method -- it shows a sample of getting a WebResponse
 
Got it now but now I get this error.

The underlying connection was closed: Could not establish trust relationship with remote server.

Any ideas on what to look for?

Hmmm.... Are you making an http:// request or a secure https://
request?

Can the same URL be used in a browser without problems?
 
Back
Top