9 Replies - 1721 Views - Last Post: 21 September 2010 - 11:59 PM Rate Topic: -----

#1 chuckjessup  Icon User is offline

  • D.I.C Regular

Reputation: 33
  • View blog
  • Posts: 380
  • Joined: 26-October 09

making readable directories

Posted 18 September 2010 - 07:53 PM

I need to create a directory that I can add, remove files and even create directories in them... I have been searching online, and a lot of good ideas, but none of them seem to pan out...
Here is what I need to do:

I. I am stacking directories
mkdir app.path & "\" & year

mkdir app.path & "\" & year & "\" & month

Then I am trying to wite a file to the "year" path so that I can reference it later and use it to open the month folder...

I run into problems, when attempting to add the files and directories because all my directories are created as read-only, so I get a permissions access error. (75 I think)

Is there a way in code to create a directory with out the read only attribute.

I found this online, however am not so sure what to do with it:
 SetAttr strFileName, GetAttr(strFileName) And (Not vbReadOnly) 
Needless to say I think it is only for files, if so then i create the files with out the read-only attribute, it seems that the directories are the issue.

I have also attempted:
mkdir app.path & "\directory" -r

Public Sub rem_RO(Path32 As String)
'lets see if that works ( tried Not vbReadOnly too but only got "error 5 invalid procedure"'
SetAttr Path32, vbDirectory

End Sub


a question, would this work, or would it be read-only?
dim FSO as new FileSystemObject
FSO.CreateFile(app.path & "\" & directory)




Any help with this would be greatly appreciated,

Jesse Fender

This post has been edited by chuckjessup: 18 September 2010 - 08:17 PM


Is This A Good Question/Topic? 0
  • +

Replies To: making readable directories

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,770
  • Joined: 26-March 09

Re: making readable directories

Posted 19 September 2010 - 01:20 AM

Jesse,

I believe by default the folders created would inherit the attributes of the parent folder.

How are you determining that the folders are readonly? By using windows explorer? There are lots of threads on google about how explorer "shows" folders as readonly when they aren't. It can be to do with whether they have cusomtisations or other things, but it doesn't affect the ability to create files (it actually uses a tri-state checkbox, so there is an undetermined state). Also the fact that you can create subfolders, suggests it isn't.

To truly see if it is read only open a command prompt and type the following:

attrib <folder name>

If the folder is truly read-only the result would look similar to as follows:

R c:\<folder name> (Note the R means read only).



Back to your question. Can you post some code that you're using to create the folders and files in the folders (not just snippets), as it may well be somewhere else that the issue lies.

This post has been edited by maj3091: 19 September 2010 - 01:21 AM

Was This Post Helpful? 0
  • +
  • -

#3 chuckjessup  Icon User is offline

  • D.I.C Regular

Reputation: 33
  • View blog
  • Posts: 380
  • Joined: 26-October 09

Re: making readable directories

Posted 20 September 2010 - 03:25 PM

View Postmaj3091, on 18 September 2010 - 11:20 PM, said:

Jesse,

I believe by default the folders created would inherit the attributes of the parent folder.

How are you determining that the folders are readonly? By using windows explorer? There are lots of threads on google about how explorer "shows" folders as readonly when they aren't. It can be to do with whether they have cusomtisations or other things, but it doesn't affect the ability to create files (it actually uses a tri-state checkbox, so there is an undetermined state). Also the fact that you can create subfolders, suggests it isn't.

To truly see if it is read only open a command prompt and type the following:

attrib <folder name>

If the folder is truly read-only the result would look similar to as follows:

R c:\<folder name> (Note the R means read only).



Back to your question. Can you post some code that you're using to create the folders and files in the folders (not just snippets), as it may well be somewhere else that the issue lies.



OK I will send you copies of the subs where I have made folders, but the snippets are literally the the code I used.
Making the "/User/" file where users files all are created and files are stored...
Private Sub Command1_Click()
Dim InputFile As String, OutputFile As String, PasswordKey As String
Dim jesse As New TCPdllpjt.Class1
'creating the user directory for later use.
    MkDir App.Path & "\User"
    Call Form1.rem_RO(App.Path & "\User")
    Dim udir As Object
    Set udir = CreateObject("scripting.filesystemobject")
    If udir.FileExists(App.Path & "\User\dir.dll") Then
    Open App.Path & "\User\dir.dll" For Output As #1
        Print #1, "khdf8796390876ysdjkfjsgfukw67584 rHJGQW12YJHLKJH43789165865UYGFJGC67235BB87T632VC9B87jhgfjhgasdjab3evauyctrawdhgasjdjhdlrkjf7e8osfy3wlhzlst6rb:O__)*!@&^*&%(*&Y@#$JHY*&%GJHT*$*^!#@%$(&@%^(^KHGDJsjghd7625483765&^%&^57634uygjhgf865^%#%@#7659jdgfj><:Opustgkjh"
        Print #1, "jkdshlfkjyhesr7862398746u8yastdjjsjjn2nwytsgfgfqv5&#$^%$(&^T)@*&^OGRGBD%I&^TCBK@N%^@vb 38956 cqi7wzs6bv65zxkbzw876b v,..aowalw57le4i5,xseltrbvl5v6zoxr67vkzyuver7vG^&%@^%&$(*&^!)*&^$(^%&%^#()*#^$*&(@%)*($!^%(356)%@)*$#&^!)*&%$!)#$608276uyweljr87s6rgJT&^WE$%&QTJrguywyt57"
    Close #1
    Else
    Open App.Path & "\User\dir.dll" For Output As #1
        Print #1, "khdf8796390876ysdjkfjsgfukw67584 rHJGQW12YJHLKJH43hdhhgfkjsayya65732517qydgjhg674NAS8I634VBI83SAKB634IAV8O376BV4O8QCN687kjhdlrkjf7e8osfy3wlhzlst6rb:O__)*!@&^*&%(*&Y@#$JHY*&%GJHT*$*^!#@%$(&@%^(^KHGDJsjghd7625483765&^%&^57634uygjhgf865^%#%@#7659jdgfj><:Opustgkjh"
        Print #1, "jkdshlfkjyhjgfjhgjsnwnnnewgjadtsjktfjksf46u8yastdjkawhkrjgfku765&#$^%$(&^T)@*&^OGRGBD%I&^TCBK@N%^@vb 38956 cqi7wzs6bv65zxkbzw876b v,..aowalw57le4i5,xseltrbvl5v6zoxr67vkzyuver7vG^&%@^%&$(*&^!)*&^$(^%&%^#()*#^$*&(@%)*($!^%(356)%@)*$#&^!)*&%$!)#$608276uyweljr87s6rgJT&^WE$%&QTJrguywyt57"
    Close #1
    End If
    
InputFile = App.Path & "\User\dir.dll"
OutputFile = App.Path & "\User\dir.dll"
PasswordKey = "sjkldfhwejrhlkhrjhwelkhrhlaiuyerlkjasdhfkjashdflkjzbxncv,mxzbvmb<>Mvz/xgvjlk;seoguiwpetypidhv.kdaf'fdlksd;fs]f\sfwept=e[tgujd;skfhkq3j4yrt987w6etruihrdjfhmdsfkajweyr3o786598q7tyt&^%$*^%#$^%$(&^%)*&%(^#%@$^$%%^&*)(&_(@*&(*^@(*&^!_(*&^~+_&_~`7-987219-384730987ueiyhrfaksyt87sdasgdfjkzbhdkjcfhyalwyr6lgHLDKSJRHGLKEJ3HYT7894W6RJHFLKAJHFO87A5URH;KNHJ;FKZHGHJSTGF8736OR;F;'A]]A;G/<.V/SDF.AAOIA3657ehhehe83Q6TUYLJAHGLKAYUR8976W34GHLTKYSADFLTAJHlkjsdhf746w4578931-39571036478659187634=-0__)&%$@&$)!(#&)$*&%*&^%@%!^@*&^$#!)*&^^/>%!@$#(&^!%)*@$&^!_($*&!@)(*&$6!(%&^~(%!(&%^)*&$^@)#(*%^(*"
Call jesse.Sub_FileEncodeAndDecode(InputFile, OutputFile, PasswordKey)

'set the button to disable itself after being pressed. preventing errors or duplicate files.
    Command1.Enabled = False
'end setting disable button

End Sub



Making the individual user folders...

'create the user file. and set up the password file.
    'On Error GoTo jim_err
    If Text2.Text <> "" Then
        If Text3.Text <> "" Then
        If Text1.Text <> "" Then
            MkDir App.Path & "\User\" & Text1.Text
            Call Form1.rem_RO(App.Path & "\User\" & Text1.Text)
            Dim pwrd As Object
            Set pwrd = CreateObject("scripting.filesystemobject")
            If pwrd.FileExists(App.Path & "\User\" & Text1.Text & "\Pwfile.dll") Then
                Open App.Path & "\User\" & Text1.Text & "\Pwfile.dll" For Output As #2
                    Print #2, Text2.Text
                Close #2
            Else
                Open App.Path & "\User\" & Text1.Text & "\Pwfile.dll" For Output As #2
                    Print #2, Text2.Text
                Close #2
            End If
            Dim usr As Object
            Set usr = CreateObject("scripting.filesystemobject")
            If usr.FileExists(App.Path & "\User\" & Text1.Text & "\user.dat") Then
                Open App.Path & "\User\" & Text1.Text & "\user.dat" For Output As #4
                    Print #4, Text1.Text
                Close #4
            Else
                Open App.Path & "\User\" & Text1.Text & "\user.dat" For Output As #4
                    Print #4, Text1.Text
                Close #4
            End If
            'set date stamp
            Dim dte As Object
            Set dte = CreateObject("scripting.filesystemobject")
            If dte.FileExists(App.Path & "\User\" & Text1.Text & "\login.dat") Then
                Open App.Path & "\User\" & Text1.Text & "\login.dat" For Output As #6
                    Print #6, "Never"
                Close #6
            Else
                Open App.Path & "\User\" & Text1.Text & "\login.dat" For Output As #6
                    Print #6, "Never"
                Close #6
            End If
        End If
        End If
    End If
On Error Resume Next
InputFile = App.Path & "\User\" & Text1.Text & "\Pwfile.dll"
OutputFile = App.Path & "\User\" & Text1.Text & "\Pwfile.dll"
PasswordKey = "jimmywenttothestoretobuy1524377dollarsand54centsworthoffoodandsuppliesthatshouldlasthimforatleastamonthyeshedid."
Call jesse.Sub_FileEncodeAndDecode(InputFile, OutputFile, PasswordKey)
'On Error Resume Next 'we have to decrypt the file to write to it.  'testing to see why i am not getting this to work! REMOVE ME BEFORE RELEASE!
'    InputFile = App.Path & "\User\Data.DLL"
'    OutputFile = App.Path & "\User\Data.DLL"
'    PasswordKey = "theredfoxjumppedovertherattyoldfenceonlytofindthathewashappierontheothersidesohetriedtojumpbackoverthefenceandcouldbutameandogwastheretomeethim."
Dim usr1 As Object
Set usr1 = CreateObject("scripting.filesystemobject")
If usr1.FileExists(App.Path & "\User\Data.DLL") Then
    Open App.Path & "\User\Data.DLL" For Append As #9
        Print #9, Text1.Text
    Close #9
Else
    Open App.Path & "\User\Data.DLL" For Output As #9
        Print #9, Text1.Text
    Close #9
End If
Call add_comboedit
Call pioneer_addrem


In form1.command1_click we add they year like e.g "\2010\" and the month file e.g "\January\"
Private Sub Command1_Click()
'setting wkr vars for use
    If Option2.Value = True Then
        wkr0 = Combo1.Text
        yr = Combo2.Text
    ElseIf Option1.Value = True Then
        'i think this is why it wasnt adding to the files...we will just have to see.
        wkr0 = Mid(Label3.Caption, 4, 5)
        yr = Mid(Label3.Caption, 8, 4)
        'deturmining the month name from the number.
        Dim JIM As String
        If wkr0 = "01" Then
            JIM = "January"
        ElseIf wkr0 = "02" Then
            JIM = "February"
        ElseIf wkr0 = "03" Then
            JIM = "March"
        ElseIf wkr0 = "04" Then
            JIM = "April"
        ElseIf wkr0 = "05" Then
            JIM = "May"
        ElseIf wkr0 = "06" Then
            JIM = "June"
        ElseIf wkr0 = "07" Then
            JIM = "July"
        ElseIf wkr0 = "08" Then
            JIM = "August"
        ElseIf wkr0 = "09" Then
            JIM = "September"
        ElseIf wkr0 = "10" Then
            JIM = "October"
        ElseIf wkr0 = "11" Then
            JIM = "November"
        ElseIf wkr0 = "12" Then
            JIM = "December"
        End If
        wkr0 = ""
        wkr0 = JIM
    End If
'setting paths
    Path1 = App.Path & "\User\" & Label2.Caption & "\"
    Path2 = yr & "\"
    Path3 = wkr0 & "\"
    Path0 = Path1 & Path2 & Path3
'end paths
' create dir's for inputing text files.
'    On Error Resume Next 'prevents error form halting program... change to dir.dll check before release
    MkDir Path1 & Path2 ' creates the year directory
 Call rem_RO(Path1 & Path2)
    MkDir Path0 'App.Path & "\" & Label2.Caption & "\" & yr & "\" & JIM
 Call rem_RO(Path0)
'end dir create
'create pthfle.dll files for recalling files later
    Dim pth As Object, I As Long, N As Long, G As Long
    Set pth = CreateObject("scripting.filesystemobject")
    If pth.FileExists(Path1 & "Pthfle.dll") Then
        Open Path1 & "Pthfle.dll" For Output As #1
            If yr = Mid(dte, 8, 4) Then
                Print #1, " " & Mid(dte, 8, 4)
                For I = 1 To 150
                    Print #1, yr - I
                Next I
            ElseIf yr <> Mid(dte, 8, 4) Then
                Print #1, Mid(dte, 8, 4)
                wkr1 = Mid(dte, 8, 4)
                If yr = wkr1 - 5 Then
                    Print #1, wkr1 - 1
                    Print #1, wkr1 - 2
                    Print #1, wkr1 - 3
                    Print #1, wkr1 - 4
                    Print #1, wkr1 - 5
                ElseIf yr = wkr1 - 4 Then
                    Print #1, wkr1 - 1
                    Print #1, wkr1 - 2
                    Print #1, wkr1 - 3
                    Print #1, wkr1 - 4
                ElseIf yr = wkr1 - 3 Then
                    Print #1, wkr1 - 1
                    Print #1, wkr1 - 2
                    Print #1, wkr1 - 3
                ElseIf yr = wkr1 - 2 Then
                    Print #1, wkr1 - 1
                    Print #1, wkr1 - 2
                ElseIf yr = wkr1 - 1 Then
                    Print #1, wkr1 - 1
                End If
                For I = 1 To 150
                    Print #1, yr - I
                Next I
            End If
        Close #1
    Else
        Open Path1 & "Pthfle.dll" For Output As #1
            If yr = Mid(dte, 8, 4) Then
                Print #1, " " & Mid(dte, 8, 4)
                For I = 1 To 150
                    Print #1, yr - I
                Next I
            ElseIf yr <> Mid(dte, 8, 4) Then
                Print #1, " " & Mid(dte, 8, 4)
                wkr1 = Mid(dte, 8, 4)
                If yr = wkr1 - 5 Then
                    Print #1, wkr1 - 1
                    Print #1, wkr1 - 2
                    Print #1, wkr1 - 3
                    Print #1, wkr1 - 4
                    Print #1, wkr1 - 5
                ElseIf yr = wkr1 - 4 Then
                    Print #1, wkr1 - 1
                    Print #1, wkr1 - 2
                    Print #1, wkr1 - 3
                    Print #1, wkr1 - 4
                ElseIf yr = wkr1 - 3 Then
                    Print #1, wkr1 - 1
                    Print #1, wkr1 - 2
                    Print #1, wkr1 - 3
                ElseIf yr = wkr1 - 2 Then
                    Print #1, wkr1 - 1
                    Print #1, wkr1 - 2
                ElseIf yr = wkr1 - 1 Then
                    Print #1, wkr1 - 1
                End If
                For I = 1 To 150
                    Print #1, yr - I
                Next I
            End If
        Close #1
    End If

    Dim pth2 As Object
    Set pth2 = CreateObject("scripting.filesystemobject")
    If pth2.FileExists(Path1 & Path2 & "Pthfle.dll") Then
        Open Path1 & Path2 & "Pthfle.dll" For Output As #2
            Print #2, "January"
            Print #2, "February"
            Print #2, "March"
            Print #2, "April"
            Print #2, "May"
            Print #2, "June"
            Print #2, "July"
            Print #2, "August"
            Print #2, "September"
            Print #2, "October"
            Print #2, "November"
            Print #2, "December"
        Close #2
    Else
        Open Path1 & Path2 & "Pthfle.dll" For Output As #2
            Print #2, "January"
            Print #2, "February"
            Print #2, "March"
            Print #2, "April"
            Print #2, "May"
            Print #2, "June"
            Print #2, "July"
            Print #2, "August"
            Print #2, "September"
            Print #2, "October"
            Print #2, "November"
            Print #2, "December"
        Close #2
    End If
'end path file creation... i dont like having to do this ,
' but it is the way it seems to be needing to be done.
Command2_Click
End Sub



In the installer it creates the directory for the program to be installed,
done in a .bat file and called from the installer...

'remember that this is from a .bat file, and is not in vb'
mkdir "C:\Program Files\TimeTracker"
mkdir "C:\Program Files\TimeTracker\Icons"
mkdir "C:\Documents and Settings\All Users\Start Menu\Programs\TimeTracker"
mkdir "C:\Program Files\TimeTracker\Sound"



The rest of the code works...

BTW what is a "tri-state" check box?
I hope this is what you were looking for, and thank you for replying.

Jesse Fender
Was This Post Helpful? 0
  • +
  • -

#4 chuckjessup  Icon User is offline

  • D.I.C Regular

Reputation: 33
  • View blog
  • Posts: 380
  • Joined: 26-October 09

Re: making readable directories

Posted 20 September 2010 - 03:31 PM

OK so I tried attrib "Folder name" and it worked out like this:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Jesse Fender>cd\

C:\>attrib "C:\Program Files\TimeTracker\User"
           C:\Program Files\TimeTracker\User

C:\>attrib "C:\Program Files\TimeTracker\User\test"
File not found - C:\Program Files\TimeTracker\User\test

C:\>attrib "C:\Program Files\TimeTracker\User\Jesse"
           C:\Program Files\TimeTracker\User\Jesse

C:\>attrib "C:\Program Files\TimeTracker\User\Jesse\2010"
           C:\Program Files\TimeTracker\User\Jesse\2010

C:\>attrib "C:\Program Files\TimeTracker"
           C:\Program Files\TimeTracker

C:\>attrib "C:\Program Files"
     R     C:\Program Files

C:\>attrib "C:\"
File not found - C:\

C:\>

Was This Post Helpful? 0
  • +
  • -

#5 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,770
  • Joined: 26-March 09

Re: making readable directories

Posted 21 September 2010 - 12:25 AM

View Postchuckjessup, on 20 September 2010 - 02:31 PM, said:

OK so I tried attrib "Folder name" and it worked out like this:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Jesse Fender>cd\

C:\>attrib "C:\Program Files\TimeTracker\User"
           C:\Program Files\TimeTracker\User

C:\>attrib "C:\Program Files\TimeTracker\User\test"
File not found - C:\Program Files\TimeTracker\User\test

C:\>attrib "C:\Program Files\TimeTracker\User\Jesse"
           C:\Program Files\TimeTracker\User\Jesse

C:\>attrib "C:\Program Files\TimeTracker\User\Jesse\2010"
           C:\Program Files\TimeTracker\User\Jesse\2010

C:\>attrib "C:\Program Files\TimeTracker"
           C:\Program Files\TimeTracker

C:\>attrib "C:\Program Files"
     R     C:\Program Files

C:\>attrib "C:\"
File not found - C:\

C:\>



Hi Jesse,

So the only readonly folder in there is "C:\Program Files" indicated by the 'R'. So we know as far as the OS is concerned, your folders are OK.

In Windows Explorer when you look at the check box for ReadOnly (depending on OS) it will just be filled in a solid colour (think it's green on XP), it is neither Checked or UnChecked, hence it's in the third state. You will probably get a better explanation than mine if you google it! :)


Glancing quickly through your code, nothing jumps out to me. What does the "Form1.rem_RO" function do? You seem to call it all the time with the FilePath that you have generated before you write any files to it?

If you debug the program and have explorer open at the same time, can you see the folders being generated as expected, and if so, does the full FilePath string look valid?

One more thing to try. I noticed that you're creating files with DLL extensions. Can you try changing them to be TXT for a test, just to rule out that the OS isn't stopping you creating the DLL files (even though they're not DLL files).
Was This Post Helpful? 0
  • +
  • -

#6 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: making readable directories

Posted 21 September 2010 - 12:45 AM

for this kind of things i have made tutorial about hiding folders in vb6. you should check it :)

EDIT:
http://www.dreaminco...9-folder-hider/
here is the sample. as you can see setting the attribute to -1 make it system folder while setting them to 0 clear all its not read only its not hidden etc. :)

EDIT: again.

it will not work on system folders any way. but it will work for folders you make

This post has been edited by NoBrain: 21 September 2010 - 01:20 AM

Was This Post Helpful? 0
  • +
  • -

#7 chuckjessup  Icon User is offline

  • D.I.C Regular

Reputation: 33
  • View blog
  • Posts: 380
  • Joined: 26-October 09

Re: making readable directories

Posted 21 September 2010 - 01:54 PM

View PostNoBrain, on 20 September 2010 - 10:45 PM, said:

for this kind of things i have made tutorial about hiding folders in vb6. you should check it :)

EDIT:
http://www.dreaminco...9-folder-hider/
here is the sample. as you can see setting the attribute to -1 make it system folder while setting them to 0 clear all its not read only its not hidden etc. :)

EDIT: again.

it will not work on system folders any way. but it will work for folders you make


Well that would be great nobrain, except I dont need to hide the folders, i am getting a file access error when i try to create files, and or add to the existing ones, it will not create the month file and puts them all in the year file, and then makes no attempt to add to those... This all worked before i added the manifest file. and i hav been a little lost as of why that would be...

maj3091, on 20 September 2010 - 10:25 PM, said:

Glancing quickly through your code, nothing jumps out to me. What does the "Form1.rem_RO" function do? You seem to call it all the time with the FilePath that you have generated before you write any files to it?

If you debug the program and have explorer open at the same time, can you see the folders being generated as expected, and if so, does the full FilePath string look valid?

One more thing to try. I noticed that you're creating files with DLL extensions. Can you try changing them to be TXT for a test, just to rule out that the OS isn't stopping you creating the DLL files (even though they're not DLL files).


for one thing rem_ro() is my attempt to remove the read only attrib from the directory. the code looks like this:
   Public Sub rem_RO(Path32 As String)
   'lets see if that works ( tried Not vbReadOnly too but only got "error 5 invalid procedure"'
   SetAttr Path32, vbDirectory
     
   End Sub



that wasn't added as it has not worked and was removed...especially when I found that the files are not read only.

I have in the past made the files as .log files, The reason that i have them as .dll files is that i dont want peopled messing with them... These files worked fine until i added the manifest file and a sound file to play in the background, other functions of the program seem to be not functioning... i dont know. I will try and go back to txt or log files. see if that fixes that ... I still have no idea as to why the folder for the month will not create.

Jesse Fender
Was This Post Helpful? 0
  • +
  • -

#8 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,770
  • Joined: 26-March 09

Re: making readable directories

Posted 21 September 2010 - 02:19 PM

Hi Jesse,

Thanks for clearing up what the Rem_Ro function was.

Another reason for the error you get is if the folder already exists?

Maybe you could try checking if the folder exists before you try to create it using the DIR function, something like:

if Len(Dir(pathname, vbDirectory)) =  0 then
mkdir (pathname)
endif



Might resolve the not creating the folders for you.

Have you debugged the variables Path1,2,3 and 0 and you're happy that they're fully qualified paths? It could be that because you're using on Error Resume next that it's actually failing on creating the folder, which in turn will stop the file being created in the folder as it doesn't exist??


The suggestion about TXT file extension was just a trial, I understand why you want to call them DLL, it's just to rule out the OS interfering with things.

This post has been edited by maj3091: 21 September 2010 - 02:24 PM

Was This Post Helpful? 1
  • +
  • -

#9 chuckjessup  Icon User is offline

  • D.I.C Regular

Reputation: 33
  • View blog
  • Posts: 380
  • Joined: 26-October 09

Re: making readable directories

Posted 21 September 2010 - 10:48 PM

View Postmaj3091, on 21 September 2010 - 12:19 PM, said:

Hi Jesse,

Thanks for clearing up what the Rem_Ro function was.

Another reason for the error you get is if the folder already exists?

Maybe you could try checking if the folder exists before you try to create it using the DIR function, something like:

if Len(Dir(pathname, vbDirectory)) =  0 then
mkdir (pathname)
endif



Might resolve the not creating the folders for you.

Have you debugged the variables Path1,2,3 and 0 and you're happy that they're fully qualified paths? It could be that because you're using on Error Resume next that it's actually failing on creating the folder, which in turn will stop the file being created in the folder as it doesn't exist??


The suggestion about TXT file extension was just a trial, I understand why you want to call them DLL, it's just to rule out the OS interfering with things.


I think you will find this funny... Do you know why I should never code when tired... because I always mix things up... I have corrected the issue... all of about ten different oppsies made my program shutter to a stop.

I will post my corrections so that others will know the value of good rest. :) Thank you Nobrain and Major, I would have never looked so hard at my code with out your prodding . the program is working like a charm, and I am very happy...

Private Sub Command1_Click()
'setting wkr vars for use'
        Dim JIM As String  'This was in the wrong place, it wouldnt work inside the if statement...'
    If Option2.Value = True Then
        JIM = Combo1.Text  'was set to the wrong variable '
        yr = Combo2.Text
    ElseIf Option1.Value = True Then
        'i think this is why it wasnt adding to the files...we will just have to see.'
        wkr0 = Mid(Label3.Caption, 5, 2) 'was pulling too many in the wrong place, instead of "09" it was "-09-2" this was where the main part of my trouble came from'
        yr = Mid(Label3.Caption, 8, 4)
        'deturmining the month name from the number.'

        If wkr0 = "01" Then
            JIM = "January"
        ElseIf wkr0 = "02" Then
            JIM = "February"
        ElseIf wkr0 = "03" Then
            JIM = "March"
        ElseIf wkr0 = "04" Then
            JIM = "April"
        ElseIf wkr0 = "05" Then
            JIM = "May"
        ElseIf wkr0 = "06" Then
            JIM = "June"
        ElseIf wkr0 = "07" Then
            JIM = "July"
        ElseIf wkr0 = "08" Then
            JIM = "August"
        ElseIf wkr0 = "09" Then
            JIM = "September"
        ElseIf wkr0 = "10" Then
            JIM = "October"
        ElseIf wkr0 = "11" Then
            JIM = "November"
        ElseIf wkr0 = "12" Then
            JIM = "December"
        End If
'        wkr0=""  ''can you see what happened here? I didnt... look below and you will see,,, comment both out....'
 '       wkr0 = JIM'
' MsgBox wkr0'
' MsgBox JIM'
'        wkr0 = "" tried this later... '
    End If
'setting paths'
    Path1 = App.Path & "\User\" & Label2.Caption & "\"
    Path2 = yr & "\"
    Path3 = JIM & "\" 'wkr0 & "\" it had a need for a "\" "in here to put files in to the directories"
    Path0 = Path1 & Path2 & Path3
'end paths'
' create dirs for inputting text files.'
    On Error Resume Next 'this works for now, '
'If Len(Dir(Path2, vbDirectory)) = 0 Then' 'I tried your suggestion and several ways none worked went to On Error Resume Next'
    MkDir Path1 & Path2 ' creates the year directory'
'End If'
'If Len(Dir(Path3, vbDirectory)) = 0 Then'
    MkDir Path0 ' App.Path & "\" & Label2.Caption & "\" & yr & "\" & JIM'
'End If'
'end dir create'


Really then you can see the need to proof read your own code... I am sorry that I didnt catcxh that sooner, and again Thanks for all the help...

Jesse Fender
Was This Post Helpful? 1
  • +
  • -

#10 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,770
  • Joined: 26-March 09

Re: making readable directories

Posted 21 September 2010 - 11:59 PM

Glad you got it working Jesse and don't worry about it....we all get to the point sometimes where we can't see the wood for the trees (so to speak), so it always good for people to offer suggestions (no matter how silly they may seem at the time, they might just point you in the right direction).

Strange about the DIR thing as I use that all the time to avoid such issues. :)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1