Solved

FileSystemObject -- Cant Create Object Error

Posted on 2002-07-30
10
154 Views
Last Modified: 2010-05-01
Does anyone know why I get an error (Cant Create Object) when I try this???

fs= CreateObject(Scripting.FileSystemObject)


I need to create a file system object in order to delete certain files requested by the user. This seems to be ok until I bundle my app with FailSafe.  I receive a failsafe error that states that I cant create the object.


thanks,

saki
0
Comment
Question by:sakibomber
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 32

Expert Comment

by:bhess1
ID: 7188924
YOu need quotation marks:

fs = CreateObject("Scripting.FileSystemObject")
0
 
LVL 32

Expert Comment

by:bhess1
ID: 7188926
oops - you also need a Set:

Set fs = CreateObject("Scripting.FileSystemObject")

(see what happens when you type too fast? :-)
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 75 total points
ID: 7189405
A much easier way to delete files, without any additional components such as FSO is to simply use "Kill".

Ex.

Kill "C:\Temp\Somefile.txt"

This is an intrinsic VB command so as long as you have the VB run-time engine (which is required to run your app) then this functionality is available.

the only minor issue is that you should include error-trapping in case the delete fails.
0
 
LVL 5

Expert Comment

by:jayeshshah
ID: 7191410
0
 
LVL 1

Expert Comment

by:kishore1977
ID: 7193171
A much easier way to delete files, without any additional components such as FSO is to simply use "Kill".

Ex.

Kill "C:\Temp\for.txt"

This is an intrinsic VB command so as long as you have the VB run-time engine (which is required to run your app) then this functionality is available.

the only minor issue is that you should include error-trapping in case the delete fails.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7193500
kishore1977,

Is that the best you can do?  Copy someone else's answer? This may be your first day on EE, but that is not the way we do it here.  

Do yourself a favor and re-read the EE Guidelines (http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp) regarding posting answers as comments.

Anthony
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7194130
kishore1977, I can't help but laugh.  I've seen people copy and then re-state a possible answer in their own words, but yours was a verbatim copy.  All I can think is that you liked my comment so much that you wanted to submit it as an answer.

I'm honored!

However, as Anthony pointed out, that's not the proper way to use Experts Exchange.  Welcome aboard and I hope you'll be more careful next time.  (FYI, most experts will only use the Comment button since they realize that their answers may only be part of what the questioner is seeking.)
0
 

Author Comment

by:sakibomber
ID: 7206734
Sorry for the delay.......Ive gotta reject your proposed solution kishore.  Sorry but its only fair.
0
 

Author Comment

by:sakibomber
ID: 7206738
Thank you...sorry for the delayed response. :)


saki
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7206749
sakibomber, thanks for the "A", and thanks for getting back to this Q.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 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

11 Experts available now in Live!

Get 1:1 Help Now