Sign in to follow this  
Followers 0
Qual-IT London

Filedelete

9 posts in this topic

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 )

Share this post


Link to post
Share on other sites



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?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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

Share this post


Link to post
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 )

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  
Followers 0