2015-05-18 21 views
2

我有以下代碼。此代碼的目的是使用vb.net在下拉框中讀取文本文件。請更正此代碼閱讀使用vb.net的Dropbox中的文本文件

Option Strict Off 
Imports System.Windows.Forms 
Imports System.Net 
Imports Microsoft.VisualBasic 
Imports System 
Imports System.IO 
Imports System.Text 

Public Class Form1 
private Sub Form1_Load(ByVal sender As System.Object, ByVal e As  
System.EventArgs) Handles MyBase.Load 
Dim ABC As String 
Dim myWebClient As New System.Net.WebClient 
Dim file As New 
System.IO.StreamReader(myWebClient.OpenRead("https://www.dropbox.com 
/s/82wlkg6l4idkewk/KPRAVEENSTOCKS.txt?dl=0")) 
ABC = file.ReadToEnd 
MsgBox(ABC) 
file.Close() 
Me.Close() 
End Sub 
End Class 

但我得到了Msgbox字符串作爲一些編程代碼,而不是我的文本在文本文件中。

對不起,我的英語不好。

我已經嘗試了很多次,並搜索網絡的解決方案,但我無法得到它。我請求你解決這個問題。

+3

請花點時間仔細閱讀此* *:[Ask] ...並設置Option Strict ON – Plutonix

回答

1

更改您要訪問(從www.dropbox.comdl.dropboxusercontent.com)的網址:

System.IO.StreamReader(myWebClient.OpenRead("https://dl.dropboxusercontent.com/s/82wlkg6l4idkewk/KPRAVEENSTOCKS.txt")) 

如果您訪問過www.dropbox.com的文件,那麼你會得到你試圖訪問該文件圍繞Dropbox的HTML包裝。

OR

指定,dl=1而不是在你的URL dl=0

System.IO.StreamReader(myWebClient.OpenRead("https://www.dropbox.com/s/82wlkg6l4idkewk/KPRAVEENSTOCKS.txt?dl=1"))