|
Home > Archive > IIS ASP > April 2006 > Error in CreateFolder()?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Error in CreateFolder()?
|
|
| anjelone 2006-04-27, 7:51 am |
| 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 2006-04-27, 7:51 am |
| 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 2006-04-27, 7:51 am |
| 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 "\".
| |
|
| I cant see why you would want to create a folder with a space at the end?
"anjelone" <anjelone@gmail.com> wrote in message
news:1145050862.199307.277910@j33g2000cwa.googlegroups.com...
> 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 2006-04-27, 7:51 am |
| 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...
| |
|
| I still don't understand
Why cant you just use Trim(folderName) to get rid of the space?
"anjelone" <anjelone@gmail.com> wrote in message
news:1145292844.011696.322590@i40g2000cwc.googlegroups.com...
> 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 2006-04-27, 7:52 am |
| 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" <anjelone@gmail.com> wrote in message
news:1145465804.990936.98900@t31g2000cwb.googlegroups.com...
> 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...
>
| |
| anjelone 2006-04-27, 7:52 am |
| 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" <anjelone@gmail.com> wrote in message
news:1145485691.062859.247780@j33g2000cwa.googlegroups.com...
> 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
| |
| anjelone 2006-04-27, 7:52 am |
| 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.
|
|
|
|
|