checking for folder - and advice needed
checking for folder - and advice needed
checking for folder - and advice needed
checking for folder - and advice needed
checking for folder - and advice needed
checking for folder - and advice needed checking for folder - and advice needed checking for folder - and advice needed checking for folder - and advice needed checking for folder - and advice needed checking for folder - and advice needed checking for folder - and advice needed checking for folder - and advice needed
checking for folder - and advice needed checking for folder - and advice needed
checking for folder - and advice needed
Go Back  Xtreme Visual Basic Talk > > > checking for folder - and advice needed


Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2017, 05: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!)
Code:
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
            System.IO.Directory.CreateDirectory(obsfolder)
        End If
        If System.IO.Directory.Exists(chartsfolder) = False Then
            System.IO.Directory.CreateDirectory(chartsfolder)
        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
  #2  
Old 12-08-2017, 06:58 AM
Daigon Ali Daigon Ali is offline
Regular
 
Join Date: Aug 2014
Location: London
Posts: 66
Default

Hi,
'Application.ExecutablePath' includes the application's file name. Try using 'Application.StartupPath'.
Reply With Quote
  #3  
Old 12-08-2017, 08:47 AM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 310
Default

Hi mate,
Thanks. That worked, and no error messages either!
But to prevent endless questions to this forum the point about books and tutorials remains, otherwise you guys will get fed up with me and my questions! ;-)
Reply With Quote
  #4  
Old 12-08-2017, 10:02 AM
Daigon Ali Daigon Ali is offline
Regular
 
Join Date: Aug 2014
Location: London
Posts: 66
Default

You're welcome.

I don't know about books but this site is quite useful and covers most versions of VB.
Visual Basic 2017 Tutorial - Visual Basic

I use SharpDevelop rather than VS but a few things that I soon discovered were:
  1. Brackets round all message boxes.
  2. The usual string functions Left,Right etc have to be "Microsoft.VisualBasic.Left" or you can import a reference e.g. "Imports VB = Microsoft.VisualBasic" so then you can just use "VB.Left".
  3. Syntax for a fields in an ADO recordset e.g. rs![my field] needs to be rs.Fields.Item("my field").value
  4. ADO isnull() is isDBNull()
  5. Year(Date) = Today.Year
  6. When formatting a date, the month has to be in upper case e.g. dd/MM/yy because mm donates minutes.
  7. Frame = Groupbox
  8. StatusBar = Statustrip
  9. MenuStrip instead of the menu editor.
  10. You have to save your code before you can run it even in the IDE.
  11. In a multi-select listbox, the listindex is always the first selected item.
Reply With Quote
  #5  
Old 12-17-2017, 03:28 PM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 310
Default

Thanks for that, it will be very useful! I just discovered the 'microsoft.visualbasic' and status bar stuff yesterday, Also it seems that subroutine names have to start with uppercase.
Reply With Quote
Reply

Tags
.net, folders, created, imports, false, class, form, vs2017, string, chartsfolder, vb6, obsfolder, beginner, appears, mscorlib.dll, disk, virtual, system.io.ioexception, run, exception, window, thrown, message, attached, minefield


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
checking for folder - and advice needed
checking for folder - and advice needed
checking for folder - and advice needed checking for folder - and advice needed
checking for folder - and advice needed
checking for folder - and advice needed
checking for folder - and advice needed checking for folder - and advice needed checking for folder - and advice needed checking for folder - and advice needed checking for folder - and advice needed checking for folder - and advice needed checking for folder - and advice needed
checking for folder - and advice needed
checking for folder - and advice needed
 
checking for folder - and advice needed
checking for folder - and advice needed
 
-->