Re: Settings Help
Posted: Fri Dec 10, 2010 4:52 pm
Hello Usman55,
I have created some test app here, please tell me if it's what you want.
I have created some test app here, please tell me if it's what you want.
Sharing, Teaching and Supporting coders of all ages and levels since 2009
https://www.codenstuff.com/forum/
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