Solved

File System Object - Classic ASP

Posted on 2011-03-01
2
347 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
ID: 35009766
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
ID: 35087212
Thanks
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 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