detailed scanning of unwanted files - vb.net

i am trying to make launcher for my server, but i am kinda worried, is there any way that i can make a list of unwanted files in browsed directory, and if script finds any of those files when i press this button it will show like this warning message, ive tried a couple of things but none works
Imports System.IO
Public Class imeprezime
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then
TextBox2.Text = FolderBrowserDialog1.SelectedPath
End If
End Sub
Private Sub connect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles connect.Click
Dim cleoPath As String
Dim filePath As String
filePath = System.IO.Path.Combine(TextBox2.Text, "gta_sa.exe")
cleoPath = System.IO.Path.Combine(TextBox2.Text, "cleo")
If File.Exists(filePath) Then
If Directory.Exists(cleoPath) Then
MsgBox("Pronasli smo cleo fajl u vasem GTA root folderu. Da se konektujete na server morate ga obrisati.")
Else
Dim p() As Process
p = Process.GetProcessesByName("gta_sa")
If p.Count > 0 Then
MsgBox("Vec imate pokrenut GTA San Andreas.")
Else
' Process is not running
End If
End If
Else
MsgBox("Da se konektujete morate locirati GTA San Andreas folder.")
End If
End Sub
Private Sub imeprezime_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class

Related

WebBrowser1.Navigate loop request

How can i make this code to loop urls continuously in Webbrowser1, after run trough these links one time.
This is the code i have so far, but when i run this, the Webbrowser stop with last url, wich is google.com. What i want to do is when the last url is reached i want it to start from top again, and run trough links again and again, until i exit the program.
Public Class Form1
Private WithEvents backgroundWorker1 As System.ComponentModel.BackgroundWorker
Dim l As New List(Of String)
Dim flagDC As Boolean = False
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Hide()
Button3.Show()
l = New List(Of String)
l.Add("http://bbc.com/sipeu/php/zq.php")
l.Add("http://google.com")
l.Add("http://DCWC.com/sipeu/us.php")
l.Add("http://google.com")
l.Add("http://example.com/sipeu/v.php")
l.Add("http://google.com")
backgroundWorker1 = New System.ComponentModel.BackgroundWorker
backgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker2_DoWork(ByVal sender As System.Object,
ByVal e As System.ComponentModel.DoWorkEventArgs) _
Handles backgroundWorker1.DoWork
For Each www In l
flagDC = False
WebBrowser1.Navigate(www)
Do
Loop While Not flagDC
Next
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) _
Handles WebBrowser1.DocumentCompleted
System.Threading.Thread.Sleep(1000)
flagDC = True
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Button3.Hide()
ChangeUserAgent("troll001_v2-agent34")
WebBrowser1.Navigate("http://example.com/welcome.php")
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Close()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs)
End Sub

how to make a vb program register form

How do i make a vb program register form? like you can in steam, google, Xbox live? Register on one computer and login from another Computer? For Free? Is i could like in drop box etc? I am making a game launcher program and i want to have theme sync there stuff. I Googled it no help! The only way i know how to is a offline account. It is annoying me. I am not that good in vb.net programming. Thanks!
here is my code
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Settings.sli Then
Main.show()
End If
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then
My.Settings.sli = 1
Else
My.Settings.sli = 0
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
My.Settings.user = TextBox3.Text
My.Settings.pass = TextBox4.Text
My.Settings.Save()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If My.Settings.user = TextBox1.Text And TextBox2.Text = My.Settings.pass Then
Main.Show()
Else
MsgBox("Username Or Password Wrong! Try Again!")
End If
End Sub
End Class
Thanks!

How to save data to a text file?

Basically, I have this program, where you click a link and it opens it. But it doesn't save all the links I put in. There is a name list and link list. You can add links and names with the buttons, and then open link with 'watch'. I was primarily going to use this for youtubers and streamers. Here is the code.
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim NamePath As String = ("C:\Favoriter\NameList.txt\")
Dim nsr As StreamReader
nsr = New StreamReader(NamePath)
Do Until nsr.EndOfStream
lstName.Items.Add(nsr.ReadLine)
Loop
nsr.Close()
Dim URLPath As String = ("C:\Favoriter\URLList.txt\")
Dim usr As StreamReader
usr = New StreamReader(URLPath)
Do Until usr.EndOfStream
lstURL.Items.Add(usr.ReadLine)
Loop
usr.Close()
End Sub
Private Sub Form1_Closing(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim NamePath As String = ("C:\Favoriter\NameList.txt\")
Dim nsw As StreamWriter
nsw = File.CreateText(NamePath)
Dim NameItems As String
Do Until lstName.Items.Count.Equals(0)
NameItems = lstName.Items.Item(0)
lstName.Items.RemoveAt(0)
nsw.WriteLine(NameItems)
Loop
nsw.Flush()
nsw.Close()
Dim URLPath As String = ("C:\Favoriter\URLList.txt\")
Dim usw As StreamWriter
usw = File.CreateText(URLPath)
Dim URLItems As String
Do Until lstURL.Items.Count.Equals(0)
URLItems = lstURL.Items.Item(0)
lstURL.Items.RemoveAt(0)
usw.WriteLine(URLItems)
Loop
usw.Flush()
usw.Close()
End Sub
Private Sub lblTitle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblTitle.Click
End Sub
Private Sub lstName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstName.SelectedIndexChanged
End Sub
Private Sub lstURL_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstURL.SelectedIndexChanged
End Sub
Private Sub txtName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtName.TextChanged
End Sub
Private Sub txtURL_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtURL.TextChanged
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
lstName.Items.Add(txtName.Text)
lstURL.Items.Add(txtURL.Text)
End Sub
Private Sub btnWatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWatch.Click
If lstURL.SelectedItem = True Then
Process.Start(lstURL.SelectedItem)
End If
End Sub
Private Sub lblName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblName.Click
End Sub
Private Sub lblURL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblURL.Click
End Sub
End Class
As first look i see you are using File.CreateText(Path), this function will overwrite the old file what ever it has data , so everytime after you write your data you delete them by overwriting, you can use
if File.Exists(Path) then
File.Open(Path)
else
File.CreateText(Path)
End If
like this you will not overwrite each time you write the text .

Progress Bar won't work for the third download in VB.NET

I'm trying to download 4 files simultaneously using 4 webclients. It download all 4 files simultaneously but the progress bar of first two works fine and the third progress bar exactly moves with the 1st one, and the fourth progress bar exactly moves with the 2nd one. Here's my code relevant to the issue.
Public WithEvents downloadFile1 As WebClient
Public WithEvents downloadFile2 As WebClient
Public WithEvents downloadFile3 As WebClient
Public WithEvents downloadFile4 As WebClient
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
System.Net.ServicePointManager.DefaultConnectionLimit = 10
End Sub
Private Sub startDownloadFile1()
downloadFile1 = New WebClient
Dim targetURL As String = lstURLs.Items.Item(0)
Dim destinationPath As String = "e:\Downloads\0.jpg"
downloadFile1.DownloadFileAsync(New Uri(targetURL), destinationPath)
End Sub
Private Sub startDownloadFile2()
downloadFile2 = New WebClient
Dim targetURL As String = lstURLs.Items.Item(1)
Dim destinationPath As String = "e:\Downloads\1.jpg"
downloadFile2.DownloadFileAsync(New Uri(targetURL), destinationPath)
End Sub
and similler for startDownloadFile3() and startDownloadFile()
Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
startDownloadFile1()
startDownloadFile2()
startDownloadFile3()
startDownloadFile4()
End Sub
Private Sub downloadFile1_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles downloadFile1.DownloadProgressChanged
pb1.Value = e.ProgressPercentage
End Sub
Private Sub downloadFile2_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles downloadFile2.DownloadProgressChanged
pb2.Value = e.ProgressPercentage
End Sub
Private Sub downloadFile3_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles downloadFile1.DownloadProgressChanged
pb3.Value = e.ProgressPercentage
End Sub
Private Sub downloadFile4_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles downloadFile2.DownloadProgressChanged
pb4.Value = e.ProgressPercentage
End Sub
Private Sub downloadFile3_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles **downloadFile1.**DownloadProgressChanged
pb3.Value = e.ProgressPercentage
End Sub
Private Sub downloadFile4_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles **downloadFile2.**DownloadProgressChanged
pb4.Value = e.ProgressPercentage
Change to: simple error
Private Sub downloadFile3_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles **downloadFile3.**DownloadProgressChanged
pb3.Value = e.ProgressPercentage
End Sub
Private Sub downloadFile4_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles **downloadFile4.**DownloadProgressChanged
pb4.Value = e.ProgressPercentage

Move Files using Kill in Visual Basic

I am making a desktop cleaner and I want the program to search For files extensions and move them into a new folder each named after the extension name. Here is what I have.
Public Class Form2
Private Sub Form_Load()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog
Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()
Me.FileReference.Text = MyFolderBrowser.SelectedPath
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Label1.Text = "Cleaned."
If CheckBox1.Checked = True Then
On Error Resume Next
Kill(Me.FileReference.Text("\*.txt"))
If Not Directory.Exists(FileReference.Text) Then
Directory.CreateDirectory(FileReference.Text)
End If
End If
End Sub
End Class
I want to use Kill(Me.FileReference.Text("\*.txt")) to move the files with .txt extention in the Directory which the textbox named Filereference.text contains which is extracted using MyFolderBrowser.SelectedPath.
How can I do this?
For Each foundFile As String In My.Computer.FileSystem.GetFiles( _
My.Computer.FileSystem.SpecialDirectories.MyDocuments, _
FileIO.SearchOption.SearchAllSubDirectories, "*.*")
Dim foundFileInfo As New System.IO.FileInfo(foundFile)
My.Computer.FileSystem.MoveFile(foundFile, "C:\StorageDir\" & foundFileInfo.Name)
Next