2007-04-23

Change local CultureInfo

DefaultCultureInfo="en-US"
DefaultCultureInfo="zh-TW"
 
If System.Globalization.CultureInfo.CurrentCulture.Name <> GlobalVariable.DefaultCultureInfo Then
    System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo(GlobalVariable.DefaultCultureInfo, False)
End If

2007-04-11

Downloding progress of HTTPWebRequest

Dim Req As Net.HttpWebRequest = Net.WebRequest.Create(FilePath & FileName)
            Dim Res As Net.HttpWebResponse = Req.GetResponse
            Dim TotalSize As Integer = Res.ContentLength
            PB.Maximum = TotalSize
            Dim st As IO.Stream = Res.GetResponseStream
            Dim so As IO.Stream
            so = New IO.FileStream(FolderPath & FileName, IO.FileMode.Create)
            Dim DownloadedByte As Integer = 0
            Dim by(1024) As Byte
            Dim osize As Integer = st.Read(by, 0, by.Length)
            While osize > 0
                DownloadedByte = osize + DownloadedByte
                Application.DoEvents()
                so.Write(by, 0, osize)
                PB.Value = DownloadedByte
                LabelInfo.Text = DownloadedByte & " / " & TotalSize
                LabelInfo.Refresh()
                osize = st.Read(by, 0, by.LongLength)
            End While
            so.Close()
            st.Close()