Here is an exapmle from my File Streaming chapter in Inside C# (second
edition).
using System;
using System.IO;
using System.Net;
namespace WebPages
{
public class WebPagesApp
{
[STAThread]
public static void Main(string[] args)
{
string s = "http://www.microsoft.com";
Uri uri = new Uri(s);
WebRequest req = WebRequest.Create(uri);
WebResponse resp = req.GetResponse();
Stream str = resp.GetResponseStream();
StreamReader sr = new StreamReader(str);
string t = sr.ReadToEnd();
int i = t.IndexOf("<HEAD>");
int j = t.IndexOf("</HEAD>");
string u = t.Substring(i, j);
Console.WriteLine("{0}", u);
}
}
}
Cheers,
Tom Archer
Author, Inside C#
-----Original Message-----
From: The DOTNET list will be retired 7/1/02
[mailto:[EMAIL PROTECTED]]On Behalf Of Jeff Roberts
Sent: Tuesday, June 25, 2002 11:53 AM
To: [EMAIL PROTECTED]
Subject: [DOTNET] FileStream question
Does anyone know if I can read a text file from a web server with the
FileStream class ? For example, if my .net application was launched from
www.ws.com\myapp.exe, could I read a file from www.ws.com by the name of
mytextfile with the following code ?
string Dir = AppDomain.CurrentDomain.BaseDirectory;
file = new FileStream(Dir+"mytextfile",
FileMode.Open,FileAccess.Read,FileShare.ReadWrite);
reader = new BinaryReader(file, Encoding.Unicode);
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.