TEL : +33 (0)9 72 13 15 17
Welcome
Services
Softwares
Competences
Contact
La boutique
Forums
Windows Forms FAQ resources
16. Windows Forms Resources
16.7 How can I save a temporary disk file from an embedded string resource?
//usage: string s = CopyResourceToTempFile(GetType(), "showcase.txt");
//where showcase.txt is an embedded resource
static string CopyResourceToTempFile(Type type, string name)
{
string temp = "";
string nsdot = type.Namespace;
if (nsdot == null)
nsdot = "";
else if (nsdot != "")
nsdot += ".";
Stream stream = type.Module.Assembly.GetManifestResourceStream(nsdot + name);
if (stream != null)
{
StreamReader sr = new StreamReader(stream);
temp = Path.GetTempFileName();
StreamWriter sw = new StreamWriter(temp, false);
sw.Write(sr.ReadToEnd());
sw.Flush();
sw.Close();
}
return temp;
}
online visitor count