Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemObject fails with Permission Denied error on creation of second file

Status
Not open for further replies.

pzh20

Programmer
Jan 17, 2015
7
GB
My application fails after creating the first directory, then copying a file into to it, then creating another directory and trying to copy another file into it.

I have tried with 2 files in the first diretory and again it fails on the second file.

Really not sure why it's failing, but here is the code and console output
[pre]
for x = 0 to ubound(ftpinvoices,2)-2
set fs=Server.CreateObject("Scripting.FileSystemObject")
If Not fs.FolderExists(temp_folder&"\ftpfiles\Weekending-" & isodate(nextupload,true)&"\"& replace(bu," ","-")&"\") then
set f=fs.CreateFolder(temp_folder&"\ftpfiles\Weekending-" & isodate(nextupload,true)&"\"& replace(bu," ","-")&"\")
f.Attributes = 0
end if
do while bu = mid(ftpinvoices(0,x),39,instr(39,ftpinvoices(0,x),"\",0)-39)
invoice = ftpinvoices(0,x)&ftpinvoices(1,x)
fromfile = invoice
response.write("from="&fromfile&VbCrLf)
tofile = temp_folder&"\ftpfiles\Weekending-" & isodate(nextupload,true)&"\"& replace(bu," ","-")&"\"
response.write("to="&tofile&VbCrLf)
fs.CopyFile fromfile,tofile,True
objTextFile.WriteLine "put " & chr(34)&invoice&chr(34)
x=x+1
if x > ubound(ftpinvoices,2)-2 then
exit do
end if
loop
bu = mid(ftpinvoices(0,x),39,instr(39,ftpinvoices(0,x),"\",0)-39)
set fs=nothing
next[/pre]

And the console output

[pre]
from=C:\Users\me\Google Drive\Invoicing\DUCK-Duck-n-Roll\Flourish\INV-2014-11-09-44529-po-DUCK00216.pdf
to=C:\inetpub\ Drive\Invoicing\HOLACG-Covent Garden\Brakes\Inv-2014-11-15-9224697868-po-HPCG04.pdf
to=C:\inetpub\ <font face="Arial" size=2>
<p>Microsoft VBScript runtime </font> <font face="Arial" size=2>error '800a0046'</font>
<p>
<font face="Arial" size=2>Permission denied</font>
<p>
<font face="Arial" size=2>/doshiweekly.asp</font><font face="Arial" size=2>, line 265</font>
[/pre]

The code is selection files with particular date ranges and copying them to another directory.

I cannot see why it would create a directory and copy a file into to it, then create the second directory and fail copying the next file. I have checked all the permissions of the source files, and the target directory, and everything looks fine.

Any help greatly welcome.

Pete
 
Because it is not permissions, that is simply the first 'excuse' it came up with for that particular error.

First off eliminate the spaces in the paths, as they are always a source of contention in scripting. By either using different locations or wrapping the paths in quotes [chr(34)]



Second:
For deity's sake please use TGML code delimiters when posting code snippets [ instructions on how to do that can be found by clicking on the 'help' icon adjacent to the [ preview ] button

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Thanks Chris,

There are no spaces in the 'to' file name, and the Google Drive name is not assigned by me. I will try putting quotes around it, but it worked the first time through.

I missed the CODE button, and will make sure I use it in future.

Regards
Pete
 
I get another error when surrounding by quotes!
Code:
from="C:\Users\pzh20\Google Drive\Invoicing\DUCK-Duck-n-Roll\Flourish\INV-2014-11-09-44529-po-DUCK00216.pdf"
to=C:\inetpub\[URL unfurl="true"]wwwroot\office.lemarcheduquartier.com\ftpfiles\Weekending-2014-11-16\DUCK-Duck-n-Roll[/URL] <font face="Arial" size=2>
<p>Microsoft VBScript runtime </font> <font face="Arial" size=2>error '800a0034'</font>
<p>
<font face="Arial" size=2>Bad file name or number</font>
<p>
<font face="Arial" size=2>/doshiweekly.asp</font><font face="Arial" size=2>, line 265</font>

Regards
Pete
 
The combination of those errors suggests that you need to terminate your path with a "\"

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Nope!
Code:
from="C:\Users\me\Google Drive\Invoicing\DUCK-Duck-n-Roll\Flourish\INV-2014-11-09-44529-po-DUCK00216.pdf"
to=C:\inetpub\[URL unfurl="true"]wwwroot\office.mysite.com\ftpfiles\Weekending-2014-11-16\DUCK-Duck-n-Roll[/URL] <font face="Arial" size=2>
<p>Microsoft VBScript runtime </font> <font face="Arial" size=2>error '800a0034'</font>
<p>
<font face="Arial" size=2>Bad file name or number</font>
<p>
<font face="Arial" size=2>/doshiweekly.asp</font><font face="Arial" size=2>, line 265</font>

Regards
Pete
 
Sorry, the cut and paste was wrong
Code:
from="C:\Users\me\Google Drive\Invoicing\DUCK-Duck-n-Roll\Flourish\INV-2014-11-09-44529-po-DUCK00216.pdf"
to=C:\inetpub\[URL unfurl="true"]wwwroot\office.mysite.com\ftpfiles\Weekending-2014-11-16\DUCK-Duck-n-Roll[/URL] <font face="Arial" size=2>
<p>Microsoft VBScript runtime </font> <font face="Arial" size=2>error '800a0034'</font>
<p>
<font face="Arial" size=2>Bad file name or number</font>
<p>
<font face="Arial" size=2>/doshiweekly.asp</font><font face="Arial" size=2>, line 265</font>

Pete
 
The slash shows when I edit the post above, but after I submit it it disappears!

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top