?
Solved

VB.Net Create if not exists

Posted on 2007-04-03
1
Medium Priority
?
6,555 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 200 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

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month17 days, 12 hours left to enroll

830 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