User Tools

Site Tools


programming:vb:vb_vs_10

Code examples for VB.net

Save file in UTF-8 format

Imports System.IO
Imports System.Text.UTF8Encoding
 
Module Module1
 
    Sub Main()
 
        'UTF-8 with BOM (Byte order mark) header
        File.WriteAllText("C:\test_file.txt", "File content", UTF8)
 
        'UTF-8 without BOM header
        Dim utf8WithoutBom As New System.Text.UTF8Encoding(False)
        File.WriteAllText("C:\test_file.txt", "File content", utf8WithoutBom)
 
    End Sub
 
End Module

Proxy and Credentials in Web Service call

Imports System.Net
 
Module Module1
 
    Sub Main()
 
        Dim oService As New Service.ServiceOdiInvoke
 
        Dim oCredential As New NetworkCredential
        oCredential.Domain = "my_domain"             'If required
        oCredential.UserName = "my_proxy_user"
        oCredential.Password = "my_proxy_password"
 
        Dim oProxy = New WebProxy
        oProxy.Address = New Uri("http://my_proxy:8080")
        oProxy.Credentials = oCredential
 
        oService.Proxy = oProxy
 
        'Call Service (example)
        oService.invoke("Param1", "Param2", "Param3")
    End Sub
 
End Module
programming/vb/vb_vs_10.txt · Last modified: 2015/09/08 16:31 by IperCube