Whats wrong with this, doesnt make sense that it wont create the folder or files.

If PathRead() = 0 Then
            MsgBox("Error Reading Path Info: One or more Paths do not exist.", MsgBoxStyle.Critical, "Path Read Error")
            MsgBox("Would you like to create these files?", MsgBoxStyle.YesNo, "Create?")
            If MsgBoxResult.Yes Then
                MkDir("/Paths/")
                System.IO.File.Create("/Paths/aPath.txt")
                System.IO.File.Create("/Paths/mPath.txt")
                System.IO.File.Create("/Paths/lPath.txt")
                System.IO.File.Create("/Paths/wPath.txt")
            End If
        End If

Recommended Answers

first import system.IO

then paste this code to your Form Load

 If Not Directory.Exists("C:\samplefolder") Then
                Directory.CreateDirectory("C:\samplefolder")
                File.Create("C:\samplefolder\sampletext.txt").Close()
            End If

after running the program try to check the directory where the folder is located...

Jump to Post

All 2 Replies

first import system.IO

then paste this code to your Form Load

 If Not Directory.Exists("C:\samplefolder") Then
                Directory.CreateDirectory("C:\samplefolder")
                File.Create("C:\samplefolder\sampletext.txt").Close()
            End If

after running the program try to check the directory where the folder is located...

Logic Error

If PathRead() = 0 Then
            MsgBox("Error Reading Path Info: One or more Paths do not exist.", MsgBoxStyle.Critical, "Path Read Error")
            MsgBox("Would you like to create these files?", MsgBoxStyle.YesNo, "Create?")
            If MsgBoxResult.Yes Then
                MkDir("/Paths/")
                System.IO.File.Create("/Paths/aPath.txt")
                System.IO.File.Create("/Paths/mPath.txt")
                System.IO.File.Create("/Paths/lPath.txt")
                System.IO.File.Create("/Paths/wPath.txt")
            End If
End If

Should be:

If PathRead() = 0 Then
            MsgBox("Error Reading Path Info: One or more Paths do not exist.", MsgBoxStyle.Critical, "Path Read Error")

            If MsgBox("Error Reading Path Info: One or more Paths do not exist." & vbcrlf & _
                      "Would you like to create these files?", MsgBoxStyle.YesNo, "Create?") = MsgBoxResult.Yes Then
                MkDir("/Paths/")
                System.IO.File.Create("/Paths/aPath.txt")
                System.IO.File.Create("/Paths/mPath.txt")
                System.IO.File.Create("/Paths/lPath.txt")
                System.IO.File.Create("/Paths/wPath.txt")
            End If
End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.