File System Object Copy File Permission Denied

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Heres what I am doing:
1. Open the merchants folder
2. Loop through the files (all images)
3. If the first letter of the filename is numeric, then thenum = left(filename,instr(filename,"_"))
4. Create folder thenum
5. Create subfolder called images under thenum folder
All that is going just file, The problem is when I am trying to copy the file from the original folder to the new folder. I am getting permission denied. I have given IUSER permission on the parent and sub-folders, and set turned the read-only
attribute off via Windows Explorer, and I still cannot write to those folders. I can write if its in the same folder.
My intention is to copy these 250 folders into their respective folders on my development machine (Win 7 Ultimate) then FTP them already in the proper folders to the production server.
Here is my code:
dim fso<br/>
set fso = server.createobject( "Scripting.FilesystemObject" )<br/>
<br/>
dim picfolderi, picfolder, thefolder, picture, mkfolder, imagesfolder, mkimagesfolder<br/>
dim filetomove, fubarfolder<br/>
picfolderi = server.mappath( "merchantpics" )<br/>
<br/>
dim objfso<br/>
set objfso = server.createobject( "scripting.filesystemobject" )<br/>
<br/>
set picfolder = objfso.getfolder( picfolderi )<br/>
for each picture in picfolder.files<br/>
if isnumeric( left( picture.name,1 ) ) then<br/>
set filetomove = objfso.getfile( picture )<br/>
thenum = left( picture.name,instr( picture.name,"_" )-1)<br/>
response.write "thenum: " & thenum & " - "<br/>
thefolder = "stores2" & thenum<br/>
imagesfolder = "stores2" & thenum & "images"<br/>
if fso.folderexists( server.mappath( thefolder ) ) then<br/>
response.write thefolder & " is already there!"<br/>
<br/>
else<br/>
response.write thefolder & " is not there - so create it!"<br/>
set mkfolder = fso.createfolder( server.mappath( thefolder ) )<br/>
response.write "<br />folder " & thefolder & " created"<br/>
set mkimagesfolder = fso.createfolder( server.mappath( imagesfolder ) )<br/>
response.write "<br />images folder created"<br/>
response.write "<br />file to move is: " & filetomove & " moving to : " & imagesfolder<br/>
filetomove.Copy(server.mappath( imagesfolder ))<br/>
response.write "file to moved was: " & filetomove<br/>
sql = "UPDATE merchants SET image_path = " & imagesfolder & "" & picture.name & " WHERE id = " & thenum<br/>
response.write "<br>sql: " & sql<br/>
oconn.execute sql <br/>
end if<br/>
response.write "<br />"<br/>
end if<br/>
next<br/>
<br/>


View the full article
 
Back
Top