Click here to Skip to main content
15,915,694 members
Home / Discussions / C#
   

C#

 
GeneralRe: Array Problem Pin
Christian Graus21-Sep-04 15:57
protectorChristian Graus21-Sep-04 15:57 
GeneralRe: Array Problem Pin
Milan200721-Sep-04 16:01
Milan200721-Sep-04 16:01 
GeneralGPS Pin
mathon21-Sep-04 14:00
mathon21-Sep-04 14:00 
GeneralRe: GPS Pin
Heath Stewart21-Sep-04 14:12
protectorHeath Stewart21-Sep-04 14:12 
GeneralRessources Exception in .NET Frameworks 2.0 Pin
Elc3p421-Sep-04 13:20
Elc3p421-Sep-04 13:20 
GeneralRe: Ressources Exception in .NET Frameworks 2.0 Pin
Heath Stewart21-Sep-04 14:27
protectorHeath Stewart21-Sep-04 14:27 
Generalembedding a resource and getting it back out Pin
vista2721-Sep-04 12:42
vista2721-Sep-04 12:42 
GeneralRe: embedding a resource and getting it back out Pin
Heath Stewart21-Sep-04 14:20
protectorHeath Stewart21-Sep-04 14:20 
ResourceManager.GetObject would not work. A ResourceManager is created for a specific .resources embedded resource.

If you change a build action for a file to "Embedded Resource", you use Assembly.GetManifestResourceStream with the full resource name ("namespace" plus file name):
private void ExtractResource(string resource, string destination)
{
  using (Stream s = this.GetType().Assembly.GetManifestResourceStream(resource))
  {
    using (FileStream file = new FileStream(destination, FileMode.Create))
    {
      int read = 0;
      byte[] buffer = new byte[4096];
      while ((read = s.Read(buffer, 0, buffer.Length)) > 0)
        file.Write(buffer, 0, read);
    }
  }
}
To use this, specify the name of the embedded resource (like "MyProject.MyFile.htm" - however the concatenation of the root namespace (configured in the Project Settings) + sub-folders + filename would look) and the destination path of the file.

For the destination, I would recommend using isolated storage which requires fewer code access security (CAS) permissions than even writing to the TEMP directory (via Path.GetTempFileName or something). See the IsolatedStorage class in the .NET Framework SDK for more information. You wouldn't have to use it, but it would make your application more robust if you planned on deploying it from different security zones (intranet or Iternet, as opposed to just running it from a local machine).

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles]
GeneralHelp :) Pin
Moon Boy21-Sep-04 11:19
Moon Boy21-Sep-04 11:19 
GeneralRe: Help :) Pin
Heath Stewart21-Sep-04 11:36
protectorHeath Stewart21-Sep-04 11:36 
GeneralUsing the Command Prompt in C# Win App Pin
chubbysilk21-Sep-04 10:06
chubbysilk21-Sep-04 10:06 
GeneralRe: Using the Command Prompt in C# Win App Pin
Heath Stewart21-Sep-04 11:08
protectorHeath Stewart21-Sep-04 11:08 
GeneralSmart Device Application Pin
mathon21-Sep-04 9:53
mathon21-Sep-04 9:53 
GeneralRe: Smart Device Application Pin
Heath Stewart21-Sep-04 11:12
protectorHeath Stewart21-Sep-04 11:12 
GeneralRe: Smart Device Application Pin
Chris Quick21-Sep-04 12:17
Chris Quick21-Sep-04 12:17 
GeneralRe: Smart Device Application Pin
mathon21-Sep-04 13:53
mathon21-Sep-04 13:53 
GeneralRe: Smart Device Application Pin
Heath Stewart21-Sep-04 14:31
protectorHeath Stewart21-Sep-04 14:31 
GeneralRe: Smart Device Application Pin
mathon21-Sep-04 22:08
mathon21-Sep-04 22:08 
GeneralHelp on setting index of dropdownlist. Pin
macsgirl21-Sep-04 9:46
macsgirl21-Sep-04 9:46 
GeneralRe: Help on setting index of dropdownlist. Pin
Colin Angus Mackay21-Sep-04 12:00
Colin Angus Mackay21-Sep-04 12:00 
GeneralRe: Help on setting index of dropdownlist. Pin
macupryk21-Sep-04 12:32
macupryk21-Sep-04 12:32 
GeneralRe: Help on setting index of dropdownlist. Pin
Colin Angus Mackay21-Sep-04 12:47
Colin Angus Mackay21-Sep-04 12:47 
GeneralRe: Help on setting index of dropdownlist. Pin
macupryk21-Sep-04 13:00
macupryk21-Sep-04 13:00 
GeneralRe: Help on setting index of dropdownlist. Pin
Colin Angus Mackay21-Sep-04 13:12
Colin Angus Mackay21-Sep-04 13:12 
GeneralConfigurable font height/width Pin
Yaron K.21-Sep-04 7:44
Yaron K.21-Sep-04 7:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.