Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Permission Denied


Reply
 
Thread Tools Display Modes
  #1  
Old 11-18-2002, 11:23 AM
MaKiT
Guest
 
Posts: n/a
Default Permission Denied


Last night I made a program which deletes a file, I used kill and it worked. Today it keeps saying permission denied! I have tryed deleting the file and making a new one, I have changed from kill to fso.deletefile and it always says 'permission denied'.
any ideas?
Reply With Quote
  #2  
Old 11-18-2002, 11:33 AM
JDT JDT is offline
Original Contributor

Retired Moderator
* Guru *
 
Join Date: Jan 2001
Location: Watch Window
Posts: 2,781
Default

Is the file open?
__________________
JDT
Reply With Quote
  #3  
Old 11-18-2002, 11:35 AM
MaKiT
Guest
 
Posts: n/a
Default

no
Reply With Quote
  #4  
Old 11-18-2002, 01:24 PM
crabby's Avatar
crabby crabby is offline
mostly gone

Retired Moderator
* Expert *
 
Join Date: Aug 2002
Location: Oppum / Rhine area
Posts: 2,721
Default

OS ?
__________________
there are always two sides of a story and 12 ways to sing a song or write some code. so whats wrong ?

Avatar by lebb
Reply With Quote
  #5  
Old 11-18-2002, 01:42 PM
DerFarm DerFarm is offline
Junior Contributor
 
Join Date: Aug 2002
Posts: 297
Default

If kill returns the message that it can't delete because of the permissions, it means that the deletion of the file is outside it's range. It can't.

Have you checked if the file is marked as passworded or is marked as read-only?
__________________
DerFarm
It IS as bad as you think
and They ARE out to get you
Reply With Quote
  #6  
Old 11-18-2002, 04:24 PM
MaKiT
Guest
 
Posts: n/a
Default

the file is just a plain text file that is not ready only or hidden or passworded
Reply With Quote
  #7  
Old 11-18-2002, 04:40 PM
JDT JDT is offline
Original Contributor

Retired Moderator
* Guru *
 
Join Date: Jan 2001
Location: Watch Window
Posts: 2,781
Default

I assume your code to delete is just a line or two but post it anyways. Maybe there is something in there causing a problem.
__________________
JDT
Reply With Quote
  #8  
Old 11-19-2002, 12:00 PM
MaKiT
Guest
 
Posts: n/a
Default

i told you that I have tryed using kill and fso and I have tryed getting code off the net and everytime the error still pops up! Also it worked the day before!

I have just done a bit of testing and the program works if the file extension is '.txt' but not if the extension is anything else. I want the extension to be '.sto' and it used to work but now it won't let me delete anything unless it has the text extension!
Reply With Quote
  #9  
Old 11-19-2002, 01:52 PM
crabby's Avatar
crabby crabby is offline
mostly gone

Retired Moderator
* Expert *
 
Join Date: Aug 2002
Location: Oppum / Rhine area
Posts: 2,721
Default

like JDT said show the code you are using evrything else is just guessing
__________________
there are always two sides of a story and 12 ways to sing a song or write some code. so whats wrong ?

Avatar by lebb
Reply With Quote
  #10  
Old 11-19-2002, 04:44 PM
MaKiT
Guest
 
Posts: n/a
Default

Ok here is the code, its a login system thing

Code:
strLength = Len(stsBar.Panels(1).Text) - 6
strLoggedOn = LCase(Right(stsBar.Panels(1).Text, strLength))

response = MsgBox("Are you sure you want to delete the user " & strLoggedOn & "?", vbYesNo  + vbQuestion)

'Delete user and all files
If response = vbYes Then
    strUserFile = "users\" & strLoggedOn & ".sto"
    Kill strUserFile
    response = MsgBox("User " & strLoggedOn & " Deleted!", vbCritical)
    mnuLogout_Click
    frmLogin.SubShow
Else
    MsgBox "User not deleted!", vbExclamation
End If
Reply With Quote
  #11  
Old 11-19-2002, 06:04 PM
Chris25NJ Chris25NJ is offline
Regular
 
Join Date: Oct 2002
Location: NJ
Posts: 96
Default

I would fully qualify the path that is being passed to Kill, that may be your problem.

if you want the \users directory that resides in the application path then use app.path & "\users\" ........
Reply With Quote
  #12  
Old 11-20-2002, 11:26 AM
MaKiT
Guest
 
Posts: n/a
Default

it worked though!! I didnt change any code it just stopped working!
Reply With Quote
  #13  
Old 11-21-2002, 12:42 AM
Chris25NJ Chris25NJ is offline
Regular
 
Join Date: Oct 2002
Location: NJ
Posts: 96
Default

did you change the location of the exe's path? moving the exe, or running in the ide vs execution will make a difference if you are not specifying the fully qualified path.
Reply With Quote
  #14  
Old 11-21-2002, 01:03 PM
MaKiT
Guest
 
Posts: n/a
Default

no i dint change or move the program, i installed Norton Anitvirus and that was about it
Reply With Quote
  #15  
Old 11-21-2002, 03:38 PM
Garmour's Avatar
Garmour Garmour is offline
Back for a little while..

Retired Leader
* Expert *
 
Join Date: Oct 2002
Location: Behind you.....Boo
Posts: 2,199
Default

is the program being used by a different user (with different permissions on folders).

Is the users folder on the network.

Could someone else have changed the permissions on the folder.

Are you the only person using this program. Does anyoneelse access you machine ?

Have you recompiled the exe ?
Things don't just stop working. Something else has changed.
And it's not the antivirus.
Something (regardless of what you think) has changed.
Either the application is no longer in the same location or
access permissions (domain user, network share,......) are stopping the program deleting.
__________________

....but then, what would I know ?
Reply With Quote
  #16  
Old 11-22-2002, 10:53 AM
MaKiT
Guest
 
Posts: n/a
Default

no its the same user doing it.
nobody else changed the permissions (and I have checked anyway)
nobody has changed the permissions or anything else relating to the program.
i have tryed compiling the exe and just running from vb
Reply With Quote
  #17  
Old 11-22-2002, 01:14 PM
Ptchaopr's Avatar
Ptchaopr Ptchaopr is offline
Junior Contributor
 
Join Date: Oct 2002
Posts: 320
Default

Try stepping through the code. Put a breakpoint right before the Kill function. See what exactly you are trying to delete (check the path being sent to Kill).

You can't delete the file if it doesn't exist, being used, or read-only.

Also, is the program running under an account that has permission to delete stuff?

It doesn't make sense why it would let you delete .txt but not .sto.

Can you manually delete the file using windows explorer? Does it give you permission denied?
Reply With Quote
  #18  
Old 11-22-2002, 02:30 PM
MaKiT
Guest
 
Posts: n/a
Default

i can manually delete it and I have set up a breakpoint and checked it and the path i correct. I'm stumped?
The username im logged on as allows deleting
Reply With Quote
  #19  
Old 11-22-2002, 02:46 PM
Ptchaopr's Avatar
Ptchaopr Ptchaopr is offline
Junior Contributor
 
Join Date: Oct 2002
Posts: 320
Default

Are you accessing the file somewhere else in the program first? It seems to be related to the program since you can manually delete it without permission denied problem.

Well, let's use windows to delete the file instead of VB then. Here's a win API you can call.

Code:
Declare Function DeleteFile Lib "kernel32.dll" Alias "DeleteFileA" (ByVal lpFileName As String) As Long ' Delete the file Dim lReturnVal As Long ' return value, just for debugging purpose Dim strUserFile as string strUserFile = "users\" & strLoggedOn & ".sto" lReturnVal = DeleteFile(strUserFile) If lReturnVal = 1 Then Debug.Print "File deleted successfully."

Brute force delete. Try it and let me know
Reply With Quote
  #20  
Old 11-22-2002, 05:24 PM
MaKiT
Guest
 
Posts: n/a
Default

I tryed your code and the file isn't deleted, the message doesnt pop up.
No I'm not accessing it somewhere else. I have unloaded all forms prior to deleting the file anyway.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->