‘retrieve current user identity
Dim wi As Security.Principal.WindowsIdentity = Security.Principal.WindowsIdentity.GetCurrent()
lblUserName.Text = wi.Name
|
|||||
|
‘retrieve current user identity ’set version number label ’set title on application Using 7zip from Visual Basic.net Option Strict On Imports System.ComponentModel Public Class SevenZip Private Shared ZipPath As String = AppController.RootPath & “7z.exe” Public Event OnZipComplete(ByVal ZipFileName As String) Public Shared Function Extract(ByVal filename As String, ByVal zipname As String) As Process Public Shared Function Compress(ByVal filename As String, ByVal zipname As String) As Process Public Shared Function Compress(ByVal filename As String, ByVal zipnames() As String) As Process Dim args As String = “a -r -tzip ” For Each s In zipnames p.StartInfo.Arguments = args & filename & “”"” Private Structure FileCopy Public Sub New(ByVal source As String, ByVal dest As String) Public Sub CompressInNewThread(ByVal filename As String, ByVal zipname As String) ‘run zip compress in another thread Private WithEvents bw As BackgroundWorker Private Sub StartZip(ByVal sender As Object, ByVal e As DoWorkEventArgs) Handles bw.DoWork Dim p As New Process() ‘return the zip filepath Private Sub EndZip(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) Handles bw.RunWorkerCompleted End Class Public Function GotInternet() As Boolean Download multiple files listed as filenames in a text file. Public Class Form1 Private Const filenames As String = “c:\files.txt” Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim req As Net.WebRequest Do While line IsNot Nothing out = New IO.BinaryWriter(New IO.FileStream(savepath & line, IO.FileMode.OpenOrCreate)) Dim buf(4096) As Byte Do While k > 0 resp.Close() line = sr.ReadLine() End Sub End Class Public Function GetUrl() As String Private Sub RecurseDir(ByVal path As String) ‘recurse down through each folder ‘then print files My.Computer.Network.Ping(targetSystem[, timeout]) targetSystem is a string IP address, a host name, or a System.Uri instance. The optional timeout argument is supplied in milliseconds and defaults to 500. This method returns true if the ping is successful, or False on failure or no response. To ping localhost for example you would have the following My.Computer.Network.Ping(127.0.0.1timeout]) Create a new Windows Forms application, and add a TextBox control named TextBox1 and a Button control named Button1 to the form. Now add the following code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If (My.Computer.FileSystem.DirectoryExists(TextBox1.Text)) Then Dim daysInMonth As Integer = Date.DaysInMonth(Now.Year, Now.Month) MsgBox(String.Format("Number of days in the current month: {0}", daysInMonth)) |
|||||
|
Copyright © 2012 Codetuts VB.net - All Rights Reserved |
|||||