Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VB.Net Create if not exists

Posted on 2007-04-03
1
6,544 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
ID: 18841964
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

840 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