English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

This is my code:

<%
Dim myFSO, myFolder
Set myFSO = Server.CreateObject("Scripting.FileSystemObject")
Set myFolder = myFSO.GetFolder (Request.Form ("txtKeywords"))

Response.Write("Current folder is: " & myFolder.Name)

For Each fileItem In myFolder.Files
Response.Write("
" & fileItem.Name)
'declare our variables
Dim myFile, objFSO
'create instances of the objects
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set myFile = objFSO.GetFile("Request.Form ('txtKeywords') & '/' & fileItem.Name")
'display information
Response.Write "The file was last accessed on " & myFile.DateLastAccessed
'delete our object variables
Set objFSO = Nothing
Set myFile = nothing


Next
Set myFolder = nothing
Set myFSO = nothing
%>
I keep getting an error saying that it can't find the file.

2007-02-27 12:14:00 · 3 answers · asked by curtis_3862552 2 in Computers & Internet Programming & Design

txt keywords contains the path like c:\folder
thats why the code says this:
Set myFile = objFSO.GetFile("Request.Form ('txtKeywords') & '/' & fileItem.Name")
txtkeywords is the folder
then I add a slash
then the name of the file

2007-02-28 08:39:26 · update #1

3 answers

The code seems correct ok.

Heres a code in more simpler form:

path = "c:\inetpub\wwwroot\"


Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(path)


For Each objFile in objFolder.Files

filename=objfile.name
response.write filename & "
"

Next




The one thing that sticks out to me, that might be causing the problems is this line in your code:

Set myFolder = myFSO.GetFolder (Request.Form ("txtKeywords"))

What does the form field of txtKeywords look like?

You see, myFSO.Getfolder is something like this:

myFSO.GetFolder("c:\inetpub\wwwroot\somefolder\")

Does the Request("txtKeywords") also pass your path?

Probably not....

You could do something like:
Basefolder = "c:\inetpub\wwwroot\"
myFSO.GetFolder (Basefolder & Request.Form ("txtKeywords"))


What I think is going on, is your form isn't passing the full path, so it doesn't know where to look. If your Request("txtKeywords") is passing something like "HelpFolder" then asp is looking for a path of \helpfolder which is prob not correct. Now, if you were to change your txtKeywords form to pass: c:\inetpub\wwwroot\somefolder , then it would work.

2007-02-27 12:34:19 · answer #1 · answered by SharpGuy 6 · 0 0

Have you tried to use an absolute path name? some times relative paths get confused when you run the script because the script engine is in another path....

2007-02-27 12:24:46 · answer #2 · answered by Anonymous · 0 0

there's no longer something you're able to do, yet whilst the PO container extensive type is right and the city and state are your best option, the submit workplace will your best option the zip. it would in basic terms reason an afternoon or 2 postpone in getting your kit.

2016-11-26 19:42:01 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers