Solved

VB.Net Create if not exists

Posted on 2007-04-03
1
6,545 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
[X]
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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net creating Contact in Outlook 1 57
Why use this lambda? 12 64
visual studio vb.net windows onkeyup 2 30
VB.Net  Exporting Excel Woorkbook to PDF 7 60
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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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