use the following code:
private void button1_Click(object sender, EventArgs e)
{
try
{
var resourceName = "WindowsFormsApplication1.TextFile1.txt";
WriteResourceToFile(resourceName, "C:\\1.txt");
}
catch
{
MessageBox.Show("Error accessing resources!");
}
}
public void WriteResourceToFile(string resourceName, string fileName)
{
using (var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
{
using (var file = new FileStream(fileName, FileMode.Create, FileAccess.Write))
{
resource.CopyTo(file);
}
}
}
and also you can find a good explanation in the following links :
http://stackoverflow.com/questions/13031778/how-can-i-extract-a-file-from-an-embedded-resource-and-save-it-to-disk[
^]
the Embedded resource name is "YourNamespace.ResourceName.Extension" which is explaind perfectly here
http://support.microsoft.com/kb/319292[
^]