Settings Help
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
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.
You do not have the required permissions to view the files attached to this post.
I tried it but the same problem occurs. It creates a folder named Log.txt instead of a txt file.
Hello Usman55,
Alright I didn't understand you at first but now I do, here we go:
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
Okay, please tell me if there is something else.
Copyright Information
Copyright © Codenstuff.com 2020 - 2023