Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Will This piece of code Check to see the directory ex

Posted on 2004-10-05
5
Medium Priority
?
212 Views
Last Modified: 2010-04-23
I acutally used a reference from this site but I wanted to make sure and I honesly can't test it right now, Please let me know for an easy 50 pts. Thanks!


Public compiledpxp As String = "c:\cytodata\compiledpxp"
 Public save As String = "c:\cyotodata\save\originalpxp"




   If Not Len(Dir$(compiledpxp, vbDirectory)) > 0 Then
            Len(CObj((Dir$(compiledpxp, vbDirectory))).Createdirectory(compiledpxp))
        ElseIf Len(Dir$(save, vbDirectory)) > 0 Then
            Len(CObj((Dir$(save, vbDirectory))).Createdirectory(compiledpxp))
        End If
0
Comment
Question by:croag
  • 3
  • 2
5 Comments
 
LVL 1

Author Comment

by:croag
ID: 12232516
I should say - Will that little sniplet check if the given directories exsists, and if not, create them? If not, can you let me know where I'm going wrong? Thank you so much!
0
 
LVL 34

Expert Comment

by:flavo
ID: 12232558
It looks like Vb 6.0 to me

heres a .Net version that does the same thing

    Dim finfo As New System.IO.FileInfo("C:\temp\mydocuments\mfile.exe")
        Dim dir As System.IO.DirectoryInfo = finfo.Directory
        If Not dir.Exists Then
            dir.Create()
            MessageBox.Show("Directory created")
        Else
            MessageBox.Show("Directory exists")
        End If
0
 
LVL 34

Accepted Solution

by:
flavo earned 200 total points
ID: 12232577
Dim DirInfo As New DirectoryInfo("C:\Temp")
If DirInfo.Exists Then    'Directory Exists
     'You are good to go...
Else
      DirInfo.CreateSubdirectory("C:\Temp")
End If
0
 
LVL 1

Author Comment

by:croag
ID: 12232603
but there are no syntactical errors in the actual code.....how could this be?
0
 
LVL 34

Expert Comment

by:flavo
ID: 12232618
>> syntactical errors

Thats not the be all and end all.  There can be other reasons that will cause it not to work.  How did the code go that I posted
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

782 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