111
0
  • 會員登入
  • 聯絡我們
  • 123關於我們
    回主選單
    • 《熱門族群》宅經濟拉抬面板需求 面板股大漲慶祝
    • 第2篇
    • 第3篇
    • 你好
    • 客製傘有兩種?
    • 更多
  • 服務項目
    回主選單
    • 網路顧問
    • 222
    • 服務內容
    • 雨傘維修服務
    • 更多
  • 產品總覽
  • 部落格
  • Podcast
  • 最新消息
  • Join us
  • Login
  • 0
    111
  • 聯絡我們
  • 123關於我們
    《熱門族群》宅經濟拉抬面板需求 面板股大漲慶祝 第2篇 第3篇 你好 客製傘有兩種?
  • 服務項目
    網路顧問 222 服務內容 雨傘維修服務
  • 產品總覽
    3C 家具 包包 文具 wheel spacer
  • 部落格
  • Podcast
  • 最新消息
  • 文章總覽
  • 分類
  • 全部
  • 投資理財
  • 技術筆記
  • 日本旅遊
  • 網站搬家
  • 時事觀察
  • 公司經營
  • 主機架設
  • 接案
  • 遊戲心得
  • 產品開箱
  • 網頁相關
  • 金流串接
  • 遊戲經濟
  • 閒聊
  • 直銷
  • CodeIgniter
  • 真田丸
  • cpanel
  • 出書材料
222 333
  1. 首頁
  2. 部落格

.NET 存取 web

2009 Mar 10 未分類
.NET framework 存取 web 的 class 大概有以下幾種

WebClient

WebRequest

HttpWebRequest

其實我也分不出來有什麼不同



不過 WebClient 感覺是比較簡單的模組

可以直接提供下載某個URL到指定的檔案 (DownloadFile)

或是讀到一個 char array  (DownloadData)

如果要POST的話

就用 UploadData(URL, method, data)

就可以模擬 form 登入了

Dim WebClient As New System.Net.WebClient
WebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Dim ASCIIEncoding As New System.Text.ASCIIEncoding
Dim PostData As Byte() = ASCIIEncoding.GetBytes("Account=" & Account & "Password=" & Password)
Dim ResultHTML As String =
ASCIIEncoding.GetChars(WebClient.UploadData(LogInURL, "POST", PostData))

UploadData 呼叫完畢以後 也會傳回頁面

可以拿來接收桌布

所以要把收到的 Byte 寫入檔案

BinaryWriter^ bw = gcnew BinaryWriter(fileName);
bw->WriteLine("A text file is born!");
bw->Write("You can use WriteLine");
bw->WriteLine("...or just Write");
bw->WriteLine("and do {0} output too.", "formatted");
bw->WriteLine("You can also send non-text objects:");
bw->WriteLine(DateTime::Now);
bw->Close();

要用 BinaryWriter, 原本在網路上 copy 的範例是 StreamWriter

那個只能寫 text = =
  • 分享此文章

111

  • 333
  • 555
  • 777

222

  • 999
  • aaa
  • ddd

Contact us

  • 營業時間: 888
  • 聯絡電話: 555
  • 地址: 333 444
COPYRIGHT ©111 All rights reserved | Designed by 路老闆