Solved

delete file permission denied using vb6

Posted on 2010-08-14
5
1,233 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

724 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