Results 1 to 7 of 7

Thread: [RESOLVED] Making a new folder

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Location
    Saihat
    Posts
    31

    Resolved [RESOLVED] Making a new folder

    Hello everyone,
    I am having a silly problem but it is driving me crazy.
    When i try to make a new directory using mkdir or filesystemObject in VB 6 it always makes it with "read-only" attribute and then if i try to write or overwrite something in it, it tells me "Access denied". I tried to change the attribute before writing or overwriting to it using the following code:

    Function CreateFolder(sFolderName As String)
    Dim objFSO As Scripting.FileSystemObject
    Dim objFolder As Scripting.Folder
    Dim strFolderPath As String
    Dim attr As Scripting.FileAttribute
    Set objFSO = New Scripting.FileSystemObject
    Set objFolder = objFSO.CreateFolder(sFolderName)
    objFolder.Attributes = Normal
    End Function

    It does not work, if i try to change the attribute to something other than 'Normal' it would work fine. It doesn't like 'Normal' though.

    Help Please
    thanks all

  2. #2
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Re: Making a new folder

    What is the reference that u have taken to do it?
    Dont rely only on your luck. Work hard until You get success.
    vb Code:
    1. Private sub Time_ispassing
    2. While Me.Notgetsuccess
    3. trygain=tryagain+1
    4. Me.workhard
    5. wend
    6. end sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Location
    Saihat
    Posts
    31

    Red face Re: Making a new folder

    Hey look, someone finally replied. I thought this problem is simple.
    anyway, to start off, i am not sure what you are asking? but if you are asking about the additional references ,i have "microsoft scripting runtime, and Windows Script Host Object Model" and in the code I am passing the directory name. A thought that cross my mind is that, I am doing this code for my work and I beleive that because the program is actually making the directory and now me "the power user" then it creates it as a read only.
    I don't know what to make out of that but..

    thanks again

  4. #4
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Re: Making a new folder

    Hey its strange problem!!! As u said that it is working with another attribute mine is aslo working with archive but when it is normal it is not happening. Don't know why????????
    Dont rely only on your luck. Work hard until You get success.
    vb Code:
    1. Private sub Time_ispassing
    2. While Me.Notgetsuccess
    3. trygain=tryagain+1
    4. Me.workhard
    5. wend
    6. end sub

  5. #5
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Thumbs up Re: Making a new folder

    Hey!!!! Check it out. This may help you!
    Dont rely only on your luck. Work hard until You get success.
    vb Code:
    1. Private sub Time_ispassing
    2. While Me.Notgetsuccess
    3. trygain=tryagain+1
    4. Me.workhard
    5. wend
    6. end sub

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Making a new folder

    Where are you creating the folder? If you are on a restricted (non admin) account I believe it has to be within your personal documents area.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Location
    Saihat
    Posts
    31

    Re: Making a new folder

    thanks guys for your help,

    Vivek, i tried the code and it says that changing the attribute is not available. I think Penagate is right. it has to do with creating a directory in a restricted area. althought even when i have an admin previlege i got the same error. I think i need to specify the attribute before creating the directory. maybe that will work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width