1. deleting files
- Posted by buzzo Aug 18, 2014
- 1400 views
delete_file(fileName) does not remove a file.. return 0, not 1 the path, is fine.. used chdir(XXX)to set it the file does exist as does the path.. the file was created using copy_file(x,y) Using win7, eu ver 4.0.3, Win32Lib
2. Re: deleting files
- Posted by fizzpopsoft Aug 18, 2014
- 1311 views
Send us some code with the euphoria statements in it...
3. Re: deleting files
- Posted by buzzo Aug 18, 2014
- 1321 views
All puts(1........) supply expected info, except for the one commented
procedure delete_Rel_records() sequence FileName puts(1,to_string(personKey) & CrLf) db_select_table("birth") x = db_find_key(personKey) if x > 0 then puts(1,"birth " & to_string(x) & CrLf) end if --db_delete_record(x) end if db_select_table("death") x = db_find_key(personKey) if x > 0 then puts(1,"death " & to_string(x) & CrLf) end if --db_delete_record(x) end if db_select_table("parents") x = db_find_key(personKey) if x > 0 then puts(1,"parents " & to_string(x) & CrLf) end if --db_delete_record(x) end if db_select_table("spouse") x = db_find_key(personKey) if x > 0 then puts(1,"spouse " & to_string(x) & CrLf) end if --db_delete_record(x) end if db_select_table("marriages") x = db_find_key(personKey) if x > 0 then puts(1,"marriages " & to_string(x) & CrLf) end if --db_delete_record(x) end if db_select_table("relative") x = db_find_key(personKey) if x > 0 then puts(1,"relative " & to_string(x) & CrLf) end if --db_delete_record(x) end if db_select_table("citation") x = db_find_key(personKey) if x > 0 then puts(1,"citations " & to_string(x) & CrLf) end if --db_delete_record(x) end if db_select_table("photographs") x = db_find_key(personKey) if x > 0 then puts(1,"photographs " & to_string(x) & " ") FileName = db_record_data(x) puts(1,to_string(length(FileName)) ) if length(FileName)>2 then puts(1,to_string(FileName) & " ") puts(1,pathToPhoto & surName & "\\" & FileName & CrLf) if chdir(pathToPhoto & surName & "\\")=1 then puts(1,"path is " & curdir() ) --pathToPhoto & surName & CrLf) if delete_file(FileName )=1 then -- this puts(1,....) does not show up....... puts(1,"deleted " & FileName & CrLf) end if -- will leave until delete works properly --db_delete_record(x) end if end if end if end procedure
4. Re: deleting files
- Posted by ArthurCrump Aug 18, 2014
- 1279 views
The example of chdir in the user guide section 8.5.2.15 does not have a final backslash. Try removing it from your code.
What is the result of
?current_dir()
after the chdir? It is a long time since I used chdir so this may be red herring.
Arthur
5. Re: deleting files
- Posted by buzzo Aug 18, 2014
- 1283 views
The output of ? current_dir will not convert using to_string.. however, using puts(1,to_string(current_dir())) produces the correct path... same as curdir()...omitting the back slash made no diff
Thanks for your reply..
Z
6. Re: deleting files
- Posted by buzzo Aug 18, 2014
- 1256 views
The problem seems to be long file names...
How can I use long file names?
7. Re: deleting files
- Posted by DerekParnell (admin) Aug 18, 2014
- 1243 views
The problem seems to be long file names...
How can I use long file names?
Be more specific please.
Why do you think the problem is "long file names".
What is the content of FileName at the time of calling delete_file()?
8. Re: deleting files
- Posted by buzzo Aug 18, 2014
- 1242 views
when I call delete_file(FileName) when the name is "gena-1-8-14.jpg" the file is not deleted... when I call content = dir(current_dir()), that file is "listed" as with both forms of the file name: gena-1-8-14.jpg and GENA-1~1.JPG
9. Re: deleting files
- Posted by DerekParnell (admin) Aug 18, 2014
- 1245 views
when I call delete_file(FileName) when the name is "gena-1-8-14.jpg" the file is not deleted... when I call content = dir(current_dir()), that file is "listed" as with both forms of the file name: gena-1-8-14.jpg and GENA-1~1.JPG
Still not enough info.
What happens when you call delete_file() with the 'short name'?
10. Re: deleting files
- Posted by buzzo Aug 18, 2014
- 1233 views
Same result..
any way the send a screen shot of the outputs of the puts's?
11. Re: deleting files
- Posted by DerekParnell (admin) Aug 18, 2014
- 1228 views
Same result..
Have you tried not changing directories but doing this instead ...
delete_file(pathToPhoto & surName & "\\" & FileName)
13. Re: deleting files
- Posted by DerekParnell (admin) Aug 19, 2014
- 1223 views
Same result... Thanks...
Ok ... let's clear up some assumptions next.
- Does the file actually exist?
- Has the file actually been deleted but just not getting reported as such?
- Can you delete the file manually, via the console?
- Is the file open (by this application or anything else) at the time the delete_file() is being called?
- Can you display/read the contents of the file?
As for screenshots, you should be able to just do some cut&paste from the console window.
14. Re: deleting files
- Posted by irv Aug 19, 2014
- 1184 views
My usual approach to things like this is:
1. make sure I can delete the file manually - including while your program is running - maybe it's in use.
2. hard-code the file name and path in the delete_file() call, so you know it is correct, i.e. not being mangled in some way, perhaps excess or missing slashes, etc. IOW, pass delete_file() a plain old string and see what happens.
3. if the hard-coded file is deleted, then obviously previous code which builds the file/path is buggy. Add display() at each step and work your way backward until you find the place it goes wrong.
BTW: what's with the puts(1,to_string(FileName) & " ") ? Does the filename look different if you just use puts(1,FileName & " ")
15. Re: deleting files
- Posted by buzzo Aug 19, 2014
- 1244 views
Same result... Thanks...
Ok ... let's clear up some assumptions next.
- Does the file actually exist? ''''''''''' yes
- Has the file actually been deleted but just not getting reported as such? no
- Can you delete the file manually, via the console? '''''''''' can not ... the file is open... this is the most likely the problem.. will study GdiPlus ..
- Is the file open (by this application or anything else) at the time the delete_file() is being called? file is loaded and displayed using GdiPlus code
- Can you display/read the contents of the file? yes
As for screenshots, you should be able to just do some cut&paste from the console window.
16. Re: deleting files
- Posted by buzzo Aug 19, 2014
- 1296 views
The matter is resolved... this instruction "closed" the file: status=GdipDisposeImage(pImage) and was placed in my code immediately before: GdipUninitialize()
Thanks for all of your help..
Buzzo