[Help] Kleines Problem = If.Io.File. ....

  • VBScript

Es gibt 7 Antworten in diesem Thema. Der letzte Beitrag () ist von Rieu.

    [Help] Kleines Problem = If.Io.File. ....

    Mein Problem:
    Ich will das meine Datei sofort beim Start überprüft ob eine Datei vorhanden ist Also so:

    Quellcode

    1. Form1.Load
    2. Dim File As String = IO.Path(Application.ExecutablePath)
    3. If IO.File.Exists(Application.StartupPath & "\" + File + ".dll") Then
    4. Do nothing
    5. End If
    6. If If IO.File.No.Exists(Application.StartupPath & "\" + File + ".dll") Then
    7. Msgbox ("Fatal Error: Wichtige datei ist nicht Vorhanden bitte starten sich den Helper um den Fehler zu behben")
    8. End If


    so hatte ich mir das ungefair vorgestellt ;D aber klappt net -.-

    Alles klar :D

    Ok ich hab das Problem gelöst hab zwar 1 - 2 umwege genommen aber es klappt jetz wenigsten :D


    Code:

    Quellcode

    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    2. If IO.File.Exists(Application.StartupPath & "\" + "setti.dll") Then
    3. Label1.Text = "Now you can Start"
    4. Timer2.Stop
    5. End If
    6. End Sub
    7. Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    8. If Label1.Text = "Error" then
    9. Button2.Performclick
    10. Me.Close
    11. End If
    12. End Sub
    13. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    14. MsgBox("Fatal Error 107283: setti File dont Found"
    15. End Sub


    Naja wie gesagt, wahr ne notlösung mit umweg aber hat geklappt :D 8o 8o
    Umständlicher ging das nicht?

    Das ist doch schneller gelöst (ohne Timer, etc.) über:


    Visual Basic-Quellcode

    1. Set io = CreateObject("Scripting.FileSystemObject")
    2. If io.FileExists(Application.StartupPath & "\" + "setti.dll") Then
    3. MsgBox ("Gefunden")
    4. Else
    5. MsgBox ("Nicht gefunden")
    6. End If