Solved

File System Object - Classic ASP

Posted on 2011-03-01
2
346 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
replace quotes with UTF-8 character 38 97
Want the count number from this QUery 2 49
Select distinct 25 102
Query still returning duplicates 5 31
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

803 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