View Single Post
Old 12-08-2017, 04:36 AM
starmanMike starmanMike is offline
Junior Contributor
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 310
Default checking for folder - and advice needed

I have bitten the bullet and obtained VS2017 to update the app I wrote in VB6, thus I am an absolute beginner in .net! I have a startup form which needs to check for a couple of folders (which will be used later on) and if they don't exist they need to be created. In VB6 this was straightforward with declaring a FileSystemObject but in .net it seems to be different. What I have so far is this (I stsrted coding in .net literally yesterday!)
Imports System
Imports System.IO
Public Class frmStartup
    Private Sub frmStartup_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim obsfolder As String, chartsfolder As String
        obsfolder = Application.ExecutablePath & "\obs"
        chartsfolder = Application.ExecutablePath & "\charts"

        If System.IO.Directory.Exists(obsfolder) = False Then
        End If
        If System.IO.Directory.Exists(chartsfolder) = False Then
        End If

    End Sub
End Class
But when I run, I get the attached message in the immediate window:
Exception thrown: 'System.IO.IOException' in mscorlib.dll
The form appears but the folders are not created. I have made a virtual disk for my VS2017 projects.

Okay - since I am such a beginner I need a decent guide through the .net minefield. Can anyone suggest a book or tutorial? I have one from our local library but it doesn't cover everything I need for this project. It's "Beginning VB 2015" by Bryan Newsome.
Reply With Quote