Click here to Skip to main content
15,908,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm New to C# my program contain two .swf files i put it them my Resources and i want to extract them from Resources to temporary folder when i open the program and delete them when close the program i hope now you clear my question


[Update:]extract two file to tempory folder and use them and delete when the program close[/update]
Posted
Updated 19-Dec-12 23:44pm
v3
Comments
OriginalGriff 20-Dec-12 5:28am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
What "temporary files" are you talking about?
Use the "Improve question" widget to edit your question and provide better information.
Manoj Chamikara 20-Dec-12 5:30am    
i hope now you clear my question
Abhishek Pant 20-Dec-12 5:33am    
do not open your file in visual studio. just go to the folder where the file folder of that project and search swf file there. Still unclear..."temporary files"?
Manoj Chamikara 20-Dec-12 5:39am    
@Abhishek Pant i want to extract two file to tempory folder and use them and delete when the program close
Richard MacCutchan 20-Dec-12 5:43am    
Create each file in turn, read the data out of your resource and use a binary or stream writer to write their contents. When your program terminates remember to delete them. What is the difficulty you are facing?

1 solution

Oh, right - That makes a bit more sense!

Each file you add as an embedded resource is available via the Properties.Resources. So, if for example you add a flv file called MyYouTube.flv to your Resources as an embedded resource:
C#
object res = Properties.Resources.MyYouTube;
If you look at the object it will be an array of bytes, so you can just save it:
C#
fileName = Path.GetTempFileName();
File.WriteAllBytes(fileName, (byte[] res);
If you save the file name in your class, then handle the FormClosing event, you can delete the temporary file when you are done.
 
Share this answer
 
Comments
Manoj Chamikara 20-Dec-12 6:02am    
@OriginalGriff Thanks in advance
OriginalGriff 20-Dec-12 6:06am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900