Error in CreateFolder()?

Discussion in 'ASP General' started by anjelone, Apr 14, 2006.

  1. anjelone

    anjelone Guest

    Hi.

    When I use CreateFolder() to create a folder with a space at the end,
    it creates the folder successfully, but still errors out with a "Path
    not Found" error.

    For example:
    <%
    Dim strCurrentPath

    strCurrentPath = "c:\test folder \

    If Not oFO.FolderExists(strCurrentPath) Then
    oFO.CreateFolder(strCurrentPath) 'Errors on this line.
    End If
    %>

    After the folder is created, it cannot be deleted or renamed
    immediately. I think there still must be some process attached. The
    error when trying to delete it is: "Cannot delete file: Cannot read
    from the source file or disk."

    I need to be able to leave the space in for now.

    Any ideas on why this occurs?

    Thanks!
     
    anjelone, Apr 14, 2006
    #1
    1. Advertising

  2. anjelone

    anjelone Guest

    Just as a follow on, I can get around this by adding "on error" around
    the createFolder(), but I'd rather get to the bottom of the error.

    Here is an example of something I would do:

    <%
    Dim strCurrentPath
    Dim strErrNum, strErrMessage

    strCurrentPath = "c:\test folder \

    If Not oFO.FolderExists(strCurrentPath) Then
    On Error Resume Next
    oFO.CreateFolder(strCurrentPath)
    If Not oFO.FolderExists(strCurrentPath) Then
    strErrNum = Err.number
    strErrMessage = Err.Description
    End If
    On Error GoTo 0
    If Len(strErrMessage) > 0 Then
    Err.Raise strErrNum, "CreateFolder(), strErrMessage
    End If
    End If
    %>
     
    anjelone, Apr 14, 2006
    #2
    1. Advertising

  3. anjelone

    anjelone Guest

    After some investigation, it appears that if you leave off the trailing
    "\" on the path, the folder gets created successfully with no error,
    and the trailing space gets stripped off.

    Unfortunately, with FileExists() if you are looking for "c:\test
    \folder\test.txt" it won't strip and it won't match.

    On a brigher note (slightly) this is taken care of in asp.net with all
    trailing spaces removed on exists() and createfolder() with or without
    the final "\".
     
    anjelone, Apr 14, 2006
    #3
  4. anjelone

    Slim Guest

    I cant see why you would want to create a folder with a space at the end?

    "anjelone" <> wrote in message
    news:...
    > After some investigation, it appears that if you leave off the trailing
    > "\" on the path, the folder gets created successfully with no error,
    > and the trailing space gets stripped off.
    >
    > Unfortunately, with FileExists() if you are looking for "c:\test
    > \folder\test.txt" it won't strip and it won't match.
    >
    > On a brigher note (slightly) this is taken care of in asp.net with all
    > trailing spaces removed on exists() and createfolder() with or without
    > the final "\".
    >
     
    Slim, Apr 15, 2006
    #4
  5. anjelone

    anjelone Guest

    We use user input project names to create folders and then reference
    those project names to read from those folders. This is a legacy aspect
    of the system that will definitely change, but it is so integrated at
    this point that it needs to stay for the time being.

    I'm hoping it will be converted to a better system in the next 2
    months, but the show must go on until then.

    Anyway, it is interesting to see the inconsistencies and I can't be the
    first to be bitten by it...
     
    anjelone, Apr 17, 2006
    #5
  6. anjelone

    Slim Guest

    I still don't understand

    Why cant you just use Trim(folderName) to get rid of the space?

    "anjelone" <> wrote in message
    news:...
    > We use user input project names to create folders and then reference
    > those project names to read from those folders. This is a legacy aspect
    > of the system that will definitely change, but it is so integrated at
    > this point that it needs to stay for the time being.
    >
    > I'm hoping it will be converted to a better system in the next 2
    > months, but the show must go on until then.
    >
    > Anyway, it is interesting to see the inconsistencies and I can't be the
    > first to be bitten by it...
    >
     
    Slim, Apr 17, 2006
    #6
  7. anjelone

    anjelone Guest

    When beginning development, you are correct. Just use Trim or something
    similar.

    *Code written w/o vars for ease.
    So I:
    CreateFolder(TRIM("c:\test "))
    Then I want to put another folder in that first one from a different
    section of the site at a different time:
    CreateFolder(TRIM("c:\test \test2 "))

    Ooops!
    I trimmed the first CreateFolder so now when creating the second I have
    to trim both...
    CreateFolder(TRIM("c:\test ") + TRIM("\test2 "))

    And what happens when I use FileExists or FolderExists? Same
    thing....Trim's on everything.

    In my case I would have to add that in approximately 200 files of code,
    multiple times in some of them.
    For a set of code used in 16 seperate production sites, that is a lot
    of changing and a whole lot of testing.
    Not to mention that file uploading, downloading and manipulation are
    integral to our product so if something went wrong with that it would
    be a major issue.

    Again, "I'm hoping it will be converted to a better system in the next
    2 months, but the show must go on until then."

    Plus, I'm not condoning this "trailing space" practice in any way, mind
    you, it is simply the code I'm dealing with. You must understand the
    position of walking into old badly developed code and having to deal
    until you can correct it...
     
    anjelone, Apr 19, 2006
    #7
  8. anjelone

    Slim Guest

    "anjelone" <> wrote in message
    news:...
    > When beginning development, you are correct. Just use Trim or something
    > similar.
    >
    > *Code written w/o vars for ease.
    > So I:
    > CreateFolder(TRIM("c:\test "))
    > Then I want to put another folder in that first one from a different
    > section of the site at a different time:
    > CreateFolder(TRIM("c:\test \test2 "))
    >
    > Ooops!
    > I trimmed the first CreateFolder so now when creating the second I have
    > to trim both...
    > CreateFolder(TRIM("c:\test ") + TRIM("\test2 "))
    >
    > And what happens when I use FileExists or FolderExists? Same
    > thing....Trim's on everything.
    >
    > In my case I would have to add that in approximately 200 files of code,
    > multiple times in some of them.
    > For a set of code used in 16 seperate production sites, that is a lot
    > of changing and a whole lot of testing.


    where are the stored?
    lop though them

    using the 1 line of code including trim?


    > Not to mention that file uploading, downloading and manipulation are
    > integral to our product so if something went wrong with that it would
    > be a major issue.
    >
    > Again, "I'm hoping it will be converted to a better system in the next
    > 2 months, but the show must go on until then."
    >
    > Plus, I'm not condoning this "trailing space" practice in any way, mind
    > you, it is simply the code I'm dealing with. You must understand the
    > position of walking into old badly developed code and having to deal
    > until you can correct it...
    >
     
    Slim, Apr 19, 2006
    #8
  9. anjelone

    anjelone Guest

    Folder names are project names, task names, contract names, review
    names, location names and report names that users input. All files
    associated with all those things go into the folder named for that
    thing.
     
    anjelone, Apr 19, 2006
    #9
  10. anjelone

    Slim Guest

    "anjelone" <> wrote in message
    news:...
    > Folder names are project names, task names, contract names, review
    > names, location names and report names that users input. All files
    > associated with all those things go into the folder named for that
    > thing.
    >


    I'm mean in a programming sense, you must have them in a database or a array
    or something,

    there for you only have to use Trim once and loop though your collection
     
    Slim, Apr 20, 2006
    #10
  11. anjelone

    anjelone Guest

    The users still have the ability in a bunch of places to hand enter the
    names so that it all gets messed up again.
    And we pull from other datasources where there also have been trailing
    spaces.
    Its quite a mess really.
     
    anjelone, Apr 21, 2006
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hfk0
    Replies:
    2
    Views:
    21,748
  2. Suresh

    IIS 5.0: CreateFolder fails

    Suresh, Dec 11, 2003, in forum: ASP General
    Replies:
    1
    Views:
    117
    Jeff Cochran
    Dec 11, 2003
  3. Ray at
    Replies:
    1
    Views:
    234
    AndrewM
    Feb 19, 2004
  4. Bren

    CreateFolder FileSystemObject hangs

    Bren, Oct 12, 2004, in forum: ASP General
    Replies:
    4
    Views:
    215
  5. Jessard

    CreateFolder across network

    Jessard, Dec 20, 2004, in forum: ASP General
    Replies:
    7
    Views:
    178
    Jessard
    Dec 24, 2004
Loading...

Share This Page