Click here to Skip to main content
15,891,951 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: how to insert image in the database Pin
Eddy Vluggen17-Dec-14 7:23
professionalEddy Vluggen17-Dec-14 7:23 
AnswerRe: how to insert image in the database Pin
Otekpo Emmanuel17-Dec-14 6:38
Otekpo Emmanuel17-Dec-14 6:38 
QuestionPls HELP me How to print data from datagridview bind on access database Pin
Member 1131194915-Dec-14 2:06
Member 1131194915-Dec-14 2:06 
AnswerRe: Pls HELP me How to print data from datagridview bind on access database Pin
Eddy Vluggen15-Dec-14 3:04
professionalEddy Vluggen15-Dec-14 3:04 
QuestionProper us of await Pin
jkirkerx14-Dec-14 13:50
professionaljkirkerx14-Dec-14 13:50 
AnswerRe: Proper us of await Pin
Richard Deeming15-Dec-14 2:37
mveRichard Deeming15-Dec-14 2:37 
GeneralRe: Proper us of await Pin
jkirkerx16-Dec-14 7:11
professionaljkirkerx16-Dec-14 7:11 
Questionwrite the buffer to the drive Pin
jkirkerx13-Dec-14 18:58
professionaljkirkerx13-Dec-14 18:58 
Alright, I did copy this off the interwebs, sort of stuck on using the await to download a file.
I used the WebClient at first, and was able to use save as to save my file.
On this which actually waits and updates the progress, I think it works, I just can't figure out the save bytes part.

So I have this do loop, not sure if I need to save the buffer in chunks during the loop, or if the buffer has all my bytes, and just do 1 save at the end. The latter produces a bad file, it's missing pieces or something, not complete.

Dim desktop_Save As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\SqlLocalDB.msi"

Dim wc As Net.HttpWebRequest = DirectCast(Net.HttpWebRequest.Create(url), Net.HttpWebRequest)
        wc.AllowAutoRedirect = True

Dim resp = Await (New TaskFactory(Of Net.WebResponse)).StartNew(AddressOf wc.GetResponse)
p.Value = 0
p.Maximum = CInt(resp.ContentLength)
Dim rqs = resp.GetResponseStream

Dim fs As New FileStream(desktop_Save, FileMode.Create) '// I should move this before write

Dim bufsize As Integer = 1 << 16
Dim buffer(bufsize) As Byte
Dim got As Integer = 0
Dim total As Integer = 0

Do
   got = Await (New TaskFactory(Of Integer)).FromAsync _
   (AddressOf rqs.BeginRead, AddressOf rqs.EndRead, buffer, 0, bufsize, Nothing)
   total += got

   Dim m_Bytes As String = _
   "Downloading " & (Convert.ToDouble(total) / 1048576).ToString("0.00") & _
   " MB" & "  /  " & (Convert.ToDouble(p.Maximum) / 1024 \ 1024).ToString("0.00") & " MB"

   l.Text = m_Bytes
   p.Increment(got)

Loop Until got = 0

fs.Write(buffer, 0, bufsize) '// I get a incomplete file, 114 megs instead of correct 43
fs.Close()

rqs.Close()
resp.Close()

AnswerRe: write the buffer to the drive [Got It] Pin
jkirkerx14-Dec-14 8:08
professionaljkirkerx14-Dec-14 8:08 
SuggestionCalculating time gap b/w files in MSFlexgrid Pin
Member 1042199813-Dec-14 3:32
Member 1042199813-Dec-14 3:32 
GeneralRe: Calculating time gap b/w files in MSFlexgrid Pin
Richard MacCutchan13-Dec-14 4:14
mveRichard MacCutchan13-Dec-14 4:14 
QuestionGridview problems with Entity framework Pin
dilkonika11-Dec-14 16:56
dilkonika11-Dec-14 16:56 
AnswerRe: Gridview problems with Entity framework Pin
Dave Kreskowiak11-Dec-14 17:00
mveDave Kreskowiak11-Dec-14 17:00 
GeneralRe: Gridview problems with Entity framework Pin
dilkonika13-Dec-14 6:17
dilkonika13-Dec-14 6:17 
GeneralRe: Gridview problems with Entity framework Pin
Dave Kreskowiak13-Dec-14 7:40
mveDave Kreskowiak13-Dec-14 7:40 
Questiondialog, top level vs mdiparent Pin
jkirkerx11-Dec-14 11:56
professionaljkirkerx11-Dec-14 11:56 
AnswerRe: dialog, top level vs mdiparent [settled] Pin
jkirkerx11-Dec-14 13:32
professionaljkirkerx11-Dec-14 13:32 
AnswerRe: dialog, top level vs mdiparent Pin
Dave Kreskowiak11-Dec-14 13:41
mveDave Kreskowiak11-Dec-14 13:41 
GeneralRe: dialog, top level vs mdiparent Pin
jkirkerx11-Dec-14 13:48
professionaljkirkerx11-Dec-14 13:48 
GeneralRe: dialog, top level vs mdiparent Pin
Dave Kreskowiak11-Dec-14 14:44
mveDave Kreskowiak11-Dec-14 14:44 
GeneralRe: dialog, top level vs mdiparent Pin
jkirkerx11-Dec-14 16:37
professionaljkirkerx11-Dec-14 16:37 
GeneralRe: dialog, top level vs mdiparent Pin
Dave Kreskowiak11-Dec-14 16:58
mveDave Kreskowiak11-Dec-14 16:58 
GeneralRe: dialog, top level vs mdiparent Pin
jkirkerx11-Dec-14 17:35
professionaljkirkerx11-Dec-14 17:35 
GeneralRe: dialog, top level vs mdiparent Pin
Dave Kreskowiak12-Dec-14 16:18
mveDave Kreskowiak12-Dec-14 16:18 
GeneralQuestion Dave Pin
jkirkerx12-Dec-14 7:09
professionaljkirkerx12-Dec-14 7:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.