I am createing a gif file from jpg files , using a generic snipit that use MemoryStream, BinaryReader and BinaryWriter.
The gif is created fine, but when i go to delete the jpg files I get a file in use exception.
I know its inside this process(subroutine) since there are no other calls to these jpg files. Also I close and dispose of the above process(MemoryStream, BinaryReader and BinaryWriter).
After continuing the program for a few seconds I am able to go in to the folder and manual delete, but I cant figure out what is holding them open.
Which makes me think that this is the line:
Image.FromFile(Files[I]).Save(MS, ImageFormat.Gif);
but how do i wait for it to finish so i can carry on with deletion programmatically?
Or is the problem maybe elsewhere?
Related
i'm rather new to pharo and I just started another new pharo project (on version 9) and lost my image as the process crashed upon saving.
I cant even load the image anymore.
I have all the changes still in the .changes file, is there any way to file in .changes files into a new image or have Epicea apply those changes?
I can of course manually copy paste all my changes, but that would be a pain with 1500+ lines of unsaved changes.
Happy about any solutions :)
In pharo-local/ombu-sessions you'll find the epicea change stored as ombu files. You can use the code changes browser to load them. If you select the directory of them of the crashed process (of course make a backup copy first) you can apply the changes you want
I have a link
http://www.example.com/foldername/1.jpg
Is there a way to make this link usable ony once? In other words, if a user downloads this image and anyone tries to download it again (even the same user) the link will not work anymore.
You could use a VB.NET script that reads the image from a protected directory and outputs it to the response stream and then simply delete this image from the directory.
See here how to write an image to the response stream.
My program will have to be run on different computers at the same time in the future. How can I open the file when my app loads up, then deny access to anything else EXCEPT the current instance of my app? (first come first serve for access to the file).
Or a way to just flag the file in a particular way and I can run a check on Form Load to see if it is flagged or not and pseudo-lock it by just disabling any button that triggers interactions with the file.
This is just to prevent more than one person from working with the same file at once.
Basically any method to allow this will be fine. I just need a starting point and I can tweak and optimize as I go on.
You can open the file with the File.Open and pass in FileShare.None as your sharing type. This will restrict others from opening the file.
File.Open(path, FileMode.Open, FileAccess.Read, FileShare.None)
Edit:
Just guessing from some of your other questions that you are calling XElement.Load on this file later in your application. One of the overload for Load takes a Stream. The File.Open method returns you a FileStream. You could just open the file immediately on application open, and then when you are ready to read the XML file, just pass the FileStream into XElement.Load.
Situation:
(Large) PDFs are stored on an iOS device
The PDFs are encrypted using a Rijndahl algorithm
When tapping one of the PDFs, it gets decrypted and afterwards viewed using a PDF viewer I implemented. The viewer is using the Core Graphics functionality to render the document page by page.
Issue:
With the documents being large enough, encrytion will take a while.
Viewing can only be started after the whole document has been decrypted into a temp file.
I'm wondering, if there is a way to...
Pass some kind of stream to CGPDFDocument instead of a file URL
Or any other alternative to be able to view as many pages as possible whil decrpytion is continued in the background?
If you cannot split your original PDF files down to single pages (as I suspect), then the following approach should work:
A: When still decrypting:
try to open the PDF document as you already do;
try accessing the document page you are interested in;
if it does not fail, render the page;
if it fails, then you know that page is not available yet (while decrypting);
while decrypting, release the pdf document each time you try to get a new page.
B: when decryption is done: do as you are already doing.
Please note that this is just a suggestion, I have not tried this while decrypting a document, but if point 1. does not fail, then this should work.
So I decided to take a look at Smalltalk. Googling led me to Squeak and Squeak By Example. Squeak By Example tells me to drag the .image file onto the Squeak.exe icon. I do this and get an error:
"Error: No content to install"
If I load squeak.exe by itself, no error message occurs. I assume this is because it uses the image file that was included in the download from squeak.org instead of the on I'm trying to use. I've verified that the .image and .changes files are not read only and are unblocked (you know, that little button that exists on the properties dialog of a file that was downloaded from the internet).
Squeak version: Squeak-4.2-All-in-One
SBE: 1.3
What's next?
Edit:
Proceeding with the book a bit, I got to the part where you save the environment, then try to open your recently saved image. I got the same error. So it must be an issue with how I'm opening it, or an permissions thing or something. I made sure both my user and the system user have full control over the image and changes files. I also tried forcing squeak.exe to run as administrator. Still having problems.
Saving the default image while exiting instead of a save-as and simply loading squeak.exe (and the default image) worked without error. I'll look at it some more later.
It seems that when an ImageFile is specified in Squeak.ini (as is the case in Squeak-4.2-All-in-One) that image file is always used. And if you pass a file as an argument to Squeak.exe (or drag and drop it) that file is passed to the image as a source file to be executed instead.
If you want to open an image file by dropping it on the Squeak.exe icon remove the ImageFile directive from Squeak.ini