Page 2 of 2

Re: Settings Help

Posted: Fri Dec 10, 2010 4:52 pm
by Agust1337
Hello Usman55,
I have created some test app here, please tell me if it's what you want.

Re: Settings Help

Posted: Fri Dec 10, 2010 6:01 pm
by Usman55
I tried it but the same problem occurs. It creates a folder named Log.txt instead of a txt file.

Re: Settings Help

Posted: Fri Dec 10, 2010 7:10 pm
by Agust1337
Hello Usman55,
Alright I didn't understand you at first but now I do, here we go:
Code: Select all
 Dim mLog As String = "c:\log.txt"
    'Please +rep if it helped! 
    'Thanks, Agust1337 @ CodenStuff.
    Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
        'this is not neccicary needed, but I prefer using this piece of code.
        Dim dir_name As String = txtFile.Text
        If System.IO.Directory.Exists(dir_name) Then
            lbl1.Text = "This path : " & dir_name & " exists"
            btnNew.Visible = False
        Else
            lbl1.Text = "Sorry your path: " & dir_name & " does not exist"
            btnNew.Visible = True
        End If
    End Sub

    Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        'I am just using Try if any problems are with the code so you wont recieve an framework error.
        Try
            Dim fs As FileStream = Nothing
            If (Not File.Exists(mLog)) Then
                fs = File.Create(mLog)
                Using fs

                End Using
            End If
            MsgBox("Your path " & txtFile.Text & " has successfully been created!", MsgBoxStyle.Information)
        Catch ex As Exception
            MsgBox("Your path " & txtFile.Text & " could not be created.", MsgBoxStyle.Critical)
        End Try
    End Sub

    Private Sub txtFile_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFile.TextChanged
        'I use this just to make the app abit more professional
        If txtFile.Text = "" Then
            btnCheck.Enabled = False
            btnNew.Enabled = False
        Else
            btnCheck.Enabled = True
            btnNew.Enabled = True
        End If
    End Sub

Re: Settings Help

Posted: Sat Dec 11, 2010 3:21 am
by Usman55
I'll try it later!

Re: Settings Help

Posted: Sat Dec 11, 2010 5:57 pm
by Agust1337
Okay, please tell me if there is something else.