ok, having some problems with some code i wrote, and should be pritty strait forward on what it does.
if your having problems reading it, sorry, im a bit jumpy with code.
(VB.net 2005 console app)
using 2005 becouse my school as deemed it not needed to upgrade...
Code:
Imports System.IO
Imports Microsoft.visualbasic
Module modmain
Dim filename As String = "" '-----------------------------replace me
Dim check As String = "initial"
Sub Main()
Console.WriteLine("checking initial files....")
If IO.File.Exists(filename) = False Then
Console.WriteLine("External program not found")
System.Threading.Thread.Sleep(4000)
End
End If
' ask for directory
Console.WriteLine("Press enter to write your own path,")
Console.WriteLine("Or write in pass to use the default path")
Dim curdir As String = "" '------------------------------------ replace me
curdir = Console.ReadLine()
' default/pass if statement
If curdir = "Pass" Then
' sets default path of the install directory
curdir = "" '---------------------------------------------- replace me
ElseIf curdir = "pass" Then
' sets default path of the install directory
curdir = "" '---------------------------------------------- replace me
Else
' asks for custom path to the install directory
Console.WriteLine("Custom path selected")
Console.WriteLine("Please enter custom path :")
curdir = Console.ReadLine()
End If
' intitial check
' Find all folders in directory
Dim dir As New DirectoryInfo(curdir)
For Each f As DirectoryInfo In dir.GetDirectories("*.*")
look(f.ToString)
For Each g As DirectoryInfo In f.GetDirectories("*.*")
look(g.ToString)
For Each h As DirectoryInfo In g.GetDirectories("*.*")
look(h.ToString)
For Each i As DirectoryInfo In h.GetDirectories("*.*")
look(i.ToString)
For Each j As DirectoryInfo In i.GetDirectories("*.*")
look(j.ToString)
For Each k As DirectoryInfo In j.GetDirectories("*.*")
look(k.ToString)
Next
Next
Next
Next
Next
Console.WriteLine("Checking For errors...")
Next
' display highest folder
Console.WriteLine("Folder " & check & " used")
If System.IO.File.Exists(dir.ToString & "\" & check & "\" & filename) = True Then
Try
Console.WriteLine("Update complete, opening external program.")
Shell(dir.ToString & "\" & check & "\" & filename)
Console.ReadLine()
Catch ex As Exception
WriteLine("Error, could not open")
Console.WriteLine(ex)
End Try
End If
System.Threading.Thread.Sleep(2000)
End Sub
Function look(ByVal f As String) As String
' check folders
Dim currentdir As New DirectoryInfo(f)
Console.WriteLine("Searching folders")
' For each folder found, check for .exe
For Each exe As FileInfo In currentdir.GetFiles("*")
Console.WriteLine("Searching files")
If exe.ToString = "League of legends.exe" Then ' ----------------------------------------------- replace me
Console.WriteLine("Found Updated program location")
' copy file to highest directory
' please edit string below
Try
System.IO.File.Copy(filename, (Dir.ToString & "\" & f.ToString & "\" & filename), True)
check = f.ToString
' pause
Console.WriteLine("File copy Complete")
System.Threading.Thread.Sleep(2000)
Catch
Console.WriteLine("Error, could not copy")
End Try
End If
Next
Return ""
End Function
End Module
now, what it does is this...simply..
[html]
1. checks if a file that its going to copy exists.
2. askes you for a directory, or gives you a default one.
3. scans said directory, and a few more directorys in that one for "league of legends.exe" (in this case)
4. if its found, tells you, and copys the file from the start to the same directory.
5. opens the copied file.
[/html]
i cant seem to find why its not working, and i've tryed adding catch statments,
and display strings and other stuff, but i cant seem to find why its not copying...
can anybody go over it for me, and check that i havent made some stupid little error?...
btw, before start, i do make a file, and enter the info where its needed...