Solved

VB.Net Create if not exists

Posted on 2007-04-03
1
6,538 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Loop not working 29 47
How do ASP.NET and MVC work together? 4 29
vb.net checkbox 7 41
How do I prevent the pages in my site from showing up in a google search? 2 36
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

18 Experts available now in Live!

Get 1:1 Help Now