Solved

File System Object - Classic ASP

Posted on 2011-03-01
2
344 Views
Last Modified: 2012-05-11
Hi All,

I am using File System Object (FSO) to rename a file name. This is a script which I am installing on some legacy web sites. Most of the time the permissions are set correctly on the server. However, if by chance the permissions are not set to allow this then I do not want the update to happen. If there is an error I want the var BolSuccess to be set to false.

Am I doing this the right way?

Any idea?

Best regards

A.

--------------------------------------------------------------------------------------

BolSuccess = True

Set objFSO=Server.CreateObject("Scripting.FilesystemObject")
On Error resume Next

objFSO.MoveFile strPathOld, strPathNew

If Err.Number <> 0 Then            
BolSuccess = False
End If

On Error GoTo 0            
Set objFSO = nothing
0
Comment
Question by:Abiel de Groot
2 Comments
 
LVL 15

Accepted Solution

by:
pateljitu earned 500 total points
Comment Utility
Syntax looks correct, also to note if permission to file is not set correctly FileSystemObject will run into error and in that case Err.Number will have value greater than 0 which will allow flag BolSuccess as false.

Also if you need to trap description of error you could use

Err.Description
Err.Source
0
 
LVL 5

Author Closing Comment

by:Abiel de Groot
Comment Utility
Thanks
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now