Does Directory Exist

  • This is probably not the correct forum, but maybe someone will help any way.

    I need to check for a directory and create it if it does not already exist. I have a script that does several things, among them is to create the directory. It's been a l-o-n-g time since I wrote VB so I'm unsure of the syntax, but I know what I have doesn't work. I have

    If Dir$(Archive) = "" Then

    MkDir(Archive)

    End If

    Can someone please help me with the syntax?

    Tim

  • Try this:

    Imports System

    Imports System.IO

    Imports System.Data

    Imports System.Math

    Imports Microsoft.SqlServer.Dts.Runtime

    Public Class ScriptMain

    Public Sub Main()

    '

    If Not IO.Directory.Exists("C:\J") Then IO.Directory.CreateDirectory("C:\J")

    '

    Dts.TaskResult = Dts.Results.Success

    End Sub

    End Class

  • As this is an SSIS forum, you can also use the File System Task.

    😎

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply