本文介绍了在streamreader VB.NET中指定用户名/密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用指定用户自动流文本文件到文本框并传入流阅读器
StreamReader:
i am trying auto stream text file to textbox with specifying user and pass in stream reader
StreamReader:
Dim address As String = "http://www.domaintest.com/test/file.txt"
Dim webclient As NetworkCredential = "user:pass"
Dim client As WebClient = New WebClient()
Dim reader As StreamReader = New StreamReader(client.OpenRead(address))
TextBox1.Text = reader.ReadToEnd
文件位置受htaccess保护
我有什么试过:
请指教用户名/密码
File Location Protected by htaccess
What I have tried:
Please Help me for Stream text file to text box with Specifying username/password
推荐答案
Dim credentials = new NetworkCredential(username, password)
Dim webClient As New WebClient()
webClient.Credentials = credentials
Dim reader As New StreamReader(client.OpenRead(address))
这篇关于在streamreader VB.NET中指定用户名/密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!