Solved

VB.Net Create if not exists

Posted on 2007-04-03
1
6,537 Views
Last Modified: 2012-05-05
Hi,

Another VB.Net Novice Question for you.

I have a string 000xxxxyyyyzzz
I want to create a folder structure based on the string  - e.g c:\000xx\000xxxxyyyyzzz.tif
I know how to manipulate the string but what i don't know is how to create a folder that doesn't already exist. i.e. i want to check if the folder exists and then create if not and then if the file exists create if not etc.

Any help would be greatly appreciated
0
Comment
Question by:doctech
1 Comment
 
LVL 9

Accepted Solution

by:
WinterMuteUK earned 50 total points
Comment Utility
Hullo doctech,

        Dim path As String
        Dim di As System.IO.DirectoryInfo

        path = "c:\temp\doesntExist"
        di = New System.IO.DirectoryInfo(path)

        If (Not di.Exists) Then
            di.Create()
            Console.WriteLine("created folder")
        End If

        Console.WriteLine("Press ENTER to exit")
        Console.ReadLine()

that should do what you want.

Cheers

Wint.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now