-
December 6th, 2012, 02:28 PM
#1
File handling problem
Hy all!
i wrote an app which opens pictures stored on hard drive, to a picture album, and what i want is that when i want to save the album, cannot overwrite the existing files, because "they are in use by another process" (by the app itself), so is there any method to "dispose" the files from the app first, to be able to delete/overwrite them?
thanks in advance
-
December 6th, 2012, 04:04 PM
#2
Re: File handling problem
Name them as something else, close all connections to the loaded picture. Later, rename the changed file after you delete the original.
-
December 6th, 2012, 04:29 PM
#3
Re: File handling problem
the problem is that the save is done and the name is given by the same for loop, automatically, because on load to be able to be identified by the name and loaded in the correct object array
-
December 6th, 2012, 04:31 PM
#4
Re: File handling problem
and if i load an album, add pictures to it, and then save it back, the old pictures has to be overwritten, but they are also opened by the app, thats my problem
-
December 7th, 2012, 08:47 AM
#5
Re: File handling problem
Not sure how you may be doing this but if you are not editing the pictures then there is no reason to save one that already exists. That would just slow down the program and serve no real purpose. You should add some code to see if the picture already exists at the given location and if so then do not try to save it again,
I think if I were going to do an album I would have all my pictures stored in one location and then use a text file for each album to hold the filenames of the pictures and the order they should appear. This would mean that I would not have to save images when they are placed in a album just the filename and would allow the same picture to appear in more than one albumn or more than once int he same album while not needing to have more than one copy of the actual picture.
Always use [code][/code] tags when posting code.
-
December 7th, 2012, 11:17 AM
#6
Re: File handling problem
i`ve made as you said, to check if the picture exists, and save only the non-existent images, works great but it also represents an issue:
the albums and the pictures are stored in an object array, something like this: albums(album_id, picture_id) as object
the files are saved as (album_id, & "_" & picture_id, & ".jpg"), so the first picture of the fist album is 0_0.jpg
the problem with your method is that if i delete a picture, the id of that picture will get the id of the next picture, and so, and if i save the album without the picture i`ve deleted, it must overwrite the name of all pictures after the deleted one, (open them for write), but they are still open by the app itself, so the same problem occurs again.
Sorry for my bad english , im from Romania
-
December 7th, 2012, 04:07 PM
#7
Re: File handling problem
I think it would make more sense to have a seperate file for the album that holds the filenames of the pictures that are to be included. Should be very easy to do and would solve your issues as well as allowing you to be able to add the same photo to more than 1 album without needing to have more than one copy of the image. Seems like a no brainer.
Always use [code][/code] tags when posting code.
-
December 8th, 2012, 04:15 PM
#8
Re: File handling problem
Adding: The text file would be like a BATCH FILE that you can call when you want the operation to run. Run upon exit, if needed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|