Jump to content

Filedelete


Recommended Posts

  • Developers

I've been stuck here before :)

This should work right? the file doesnt get deleted as it is still open

$file = FileOpen($file, 0)

$line = FileReadLine("~locfldr.qbw")

if $line = "1" Then

FileClose($file)

FileDelete ( $file )

What is the value of $file before the first line ?

can you post a scriptlet that shows the issue when ran?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

What is the value of $file before the first line ?

can you post a scriptlet that shows the issue when ran?

the value is "0"

there is a msgbox after the filedelete and then an exit statement

when the message box is displayed the file should have gone, if you try and delete it in windows it says its in use

Link to comment
Share on other sites

  • Developers

the value is "0"

Value = 0 ???

The filename for this statement i mean ?

$file = FileOpen($file, 0)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Value = 0 ???

The filename for this statement i mean ?

$file = FileOpen($file, 0)

sorry

make a file called ~locfldr.qbw with just 1 in it

$file="~locfldr.qbw"

$file = FileOpen($file, 0)

$line = FileReadLine($file)

if $line = "1" Then

FileClose($file)

FileDelete ( $file )

Link to comment
Share on other sites

  • Developers

you are overriding the filename with the filehandle thus trying to delete a file called 1

try this one:

$filename="~locfldr.qbw"
$file = FileOpen($filename, 0)
$line = FileReadLine($file)
if $line = "1" Then
    FileClose($file)
    FileDelete($filename )
EndIf
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

you are overriding the filename with the filehandle thus trying to delete a file called 1

try this one:

$filename="~locfldr.qbw"
$file = FileOpen($filename, 0)
$line = FileReadLine($file)
if $line = "1" Then
    FileClose($file)
    FileDelete($filename )
EndIf
same :)
Link to comment
Share on other sites

  • Developers

same :)

works for me.....

did you check if it has run the filedelete ?

like:

$filename="~locfldr.qbw"
$file = FileOpen($filename, 0)
$line = FileReadLine($file)
if $line = "1" Then
    FileClose($file)
    Sleep(50)
    FileDelete($filename )
    ConsoleWrite('@@ Debug(7) : $filename = ' & $filename & @lf & '>Error code: ' & @error & '  Extended code: ' & @extended & @lf);### Debug Console
EndIf

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

works for me.....

did you check if it has run the filedelete ?

like:

$filename="~locfldr.qbw"
$file = FileOpen($filename, 0)
$line = FileReadLine($file)
if $line = "1" Then
    FileClose($file)
    Sleep(50)
    FileDelete($filename )
    ConsoleWrite('@@ Debug(7) : $filename = ' & $filename & @lf & '>Error code: ' & @error & '  Extended code: ' & @extended & @lf);### Debug Console
EndIf
ahhh!

its being opened but not closed elsewhere in the script (blush)

thank u for ur help sometimes i need to just have someone to talk it thru with

appreciate it

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...