Solved

delete file permission denied using vb6

Posted on 2010-08-14
5
1,205 Views
Last Modified: 2012-05-10
I am trying to Delete a text file but keep getting a permission denied error. I can Copy it but cannot Move or Delete it.
0
Comment
Question by:DblTMO
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:odd lie
ID: 33437166
This can happen when someone has the file in use, try to chech if the file is in use,
If in use , try to find the owner of the file and close that connection.

regards
Oldelphi
0
 

Author Comment

by:DblTMO
ID: 33437181
I am the owner. I am Importing the file into Access then St the FSO = Nothing. After that I need to Copy the file to a Backup directory. After the Copy I need to Delete the orginal.
0
 

Expert Comment

by:sha_josh
ID: 33437429
You can delete using command prompt if you have any issues with deleting using Explorer.
1. Open command prompt
2. type this below command. I have used c:\windows\test.tmp as example file you want to delete:
del /f /q c:\windows\test.tmp

This should work!
Cheers
0
 
LVL 17

Expert Comment

by:Zhaolai
ID: 33438366
Try this:

    Dim FSO As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    FSO.DeleteFile "FileToBeDeleted", True


0
 

Accepted Solution

by:
DblTMO earned 0 total points
ID: 33438399
I would like to thank those who offered solutions.  They would all worked if I had closed the Text Object. I had closed all the FSO but not the TSO. Sometimes it the easy/obvious things that stop you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 41
SLMGR Switches Are Not Working On KMS Host 3 142
VB6 - Convert HH:MM into Decimal 8 70
Passing a Text Box name to a Sub 6 102
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

749 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