473,387 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SWF as embedded resource and .NET

I know the question of whether or not a SWF file can be read in by a
..NET application has been asked a billion times, however, what I'm
asking is whether or not it is possible (any examples? tutorials? Flash
Object COM readme?) to embed a SWF file into your VS.NET project as a
resource, and then read in the file into the Flash object much the same
way that you currently do using the LoadMovie function that takes in a
layer and a file location path.

Anyone know of a way to load a SWF that is an embedded resource and not
in the physical directory path into a .NET application?

Thanks all
-Steve

Feb 14 '06 #1
1 2949
Hi,

<ph*******@comcast.net> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I know the question of whether or not a SWF file can be read in by a
.NET application has been asked a billion times, however, what I'm
asking is whether or not it is possible (any examples? tutorials? Flash
Object COM readme?) to embed a SWF file into your VS.NET project as a
resource, and then read in the file into the Flash object much the same
way that you currently do using the LoadMovie function that takes in a
layer and a file location path.

Anyone know of a way to load a SWF that is an embedded resource and not
in the physical directory path into a .NET application?


AFAIK you can insert any file as a resource, you later would have to
"de-embed" it in a temp file and feed this file to the flash player.

With the code below you check the resources for the expected name, save it
to a temp file and return the pathof the new file
Note that the original extension is also kept

static string ExtractResource( string resourceName)
{
//look for the resource name
foreach( string currentResource in
System.Reflection.Assembly.GetExecutingAssembly(). GetManifestResourceNames()
)
if ( currentResource.LastIndexOf( resourceName) != -1 )
{
string fqnTempFile = System.IO.Path.GetTempFileName();
string path = System.IO.Path.GetDirectoryName( fqnTempFile);
string rootName= System.IO.Path.GetFileNameWithoutExtension(
fqnTempFile);
string destFile = path + @"\" + rootName + "." +
System.IO.Path.GetExtension( currentResource);

System.IO.Stream fs =
System.Reflection.Assembly.GetExecutingAssembly(). GetManifestResourceStream(
currentResource);

byte[] buff = new byte[ fs.Length ];
fs.Read( buff, 0, (int)fs.Length);
fs.Close();

System.IO.FileStream destStream = new System.IO.FileStream ( destFile,
FileMode.Create);
destStream.Write( buff, 0, buff.Length);
destStream.Close();

return destFile;
}

throw new Exception("Resource not found : " + resourceName);

}
Feb 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: james | last post by:
What class / method should I be using to get the full path to an embedded resource ? In my case I have an .xml file that my app uses, it is set as embedded resource, and I have a control that...
5
by: Drew | last post by:
Assembly asm = Assembly.GetExecutingAssembly(); me = new Bitmap(asm.GetManifestResourceStream("me.gif")); I have used this before without any problem, but now I get: An unhandled exception...
1
by: n! | last post by:
I have an irritating problem with VS.NET2003, C#. I wrote some code that would build my application menu from an XML resource file. Purely to make it easy for me to edit, so I've added this file as...
2
by: Kyle Kaitan | last post by:
I have an assembly (AppResources.dll) which contains a number of embedded resource files. Most of these are key/value pairs of relevant strings; a few are images and sounds; some more are XML...
0
by: ATS | last post by:
HOWTO Make a UserControl deploy an embedded resource. Please help, I need to embed an EXE into a C# UserControl that is run from script in an HTML web page as such: <html> <object...
0
by: Johann Blake | last post by:
I'm having trouble grasping how ASP.NET correctly locates resources. There is plenty of documentation on this subject but some things are not clear at all. In my ASP.NET application, I have...
4
by: Jason Pettys | last post by:
In an ASP.NET project I am setting the content type of my .ascx and ..aspx files to Embedded Resource for a separate reason. When I do this they get embedded as "RootNamespace.Filename" but I...
3
by: raghu sunkara | last post by:
Hi, How Can i Change or Modify Embedded String Resource In An Assembly. I Need To Modify Embedded String Resource In An Assembly. Please Help Me. Thanks Raghu.
2
Frinavale
by: Frinavale | last post by:
I am attempting to use embedded resources in an Ajax Enabled ASP.NET Web Application. I'm using Visual Studio 2008 and VB.NET server side code. The project is called "EmbeddedResources" with the...
2
by: steve | last post by:
I have the following routine for retrieving error message strigs from a resource file which is embedded in the project. But when it is called I get the error messsage "Could not find any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.