请问在C#中如何访问远程文件? 急!!!!!!!

BUF 2003-10-11 08:53:50
请问如果访问分布式文件系统,
以及如何访问URI指定的文件 比如说读取文件 "http://aaa.bbb.ccc/ccc.txt"

急用!!!!!
谢谢!!!!!
...全文
143 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
BUF 2003-10-12
  • 打赏
  • 举报
回复
up
xiaodele 2003-10-11
  • 打赏
  • 举报
回复
webclient类对.config获xml类的文件会报错,不知道为什么!
速马 2003-10-11
  • 打赏
  • 举报
回复
用WebClient类,超简单
tzhguan 2003-10-11
  • 打赏
  • 举报
回复
gz
BUF 2003-10-11
  • 打赏
  • 举报
回复
thank you very much!
how about the accessing of the distributed files?
windinwing 2003-10-11
  • 打赏
  • 举报
回复
调用 string htmpstr=getPage("http://aaa.bbb.ccc/ccc.txt");

public static string getPage(String url)
{
WebResponse result = null;
string txthtml="";
try
{
WebRequest req = WebRequest.Create(url);
result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("gb2312");
StreamReader sr = new StreamReader(ReceiveStream,encode);
//this.Message.Text+="\r\n已接收到响应流";
if (true)
{
Char[] read = new Char[256];
int count = sr.Read( read, 0, 256 );

// this.Message.Text+="HTML...\r\n";
while (count > 0)
{
String str = new String(read, 0, count);
txthtml+=str;
count = sr.Read(read, 0, 256);
}
// this.Message.Text="":
}
}
catch(Exception)
{
txthtml="err";
//this.is_id.Value=url;
}
finally
{
if (result != null)
{
result.Close();
}

}
//this.is_id.Value=url;
return txthtml;
}

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧