Reputation: 13378
I want to open a Microsoft Word file(.docx). So I tried to use this code:
System.Diagnostics.Process.Start(@"C:\Users\Max\Documents\Visual Studio 2008\Projects\Verenigingspakket\Verenigingspakket\Resources\Help.docx");
But now I want to run it like this way, by using the Help.Docx from my resources:
System.Diagnostics.Process.Start(Properties.Resources.Help);
But that code doesn't work, because it is not an good overload for .Start();
Does anybody know how to work around this problem and give me a little help?
Thanks in advance
Upvotes: 0
Views: 3289
Reputation: 65077
You'll have to write it to the file system first.. perhaps like this:
using (FileStream fileStream = new FileStream(@"C:\Help.docx", FileMode.Create, FileAccess.Write))
{
using (BinaryWriter binaryWriter = new BinaryWriter(fileStream))
{
binaryWriter.Write(Properties.Resources.Help);
}
}
EDIT: I should note for those wondering: binary files within a resource are returned as byte arrays.. hence why you can pass them directly into BinaryWriter.Write()
Upvotes: 4