Reputation: 1171
I've downloaded an executable file from my Cloud blob, and now I want to run the file.
here's my relevant piece of code:
Stream codeContent = new MemoryStream();
blobClientCode.GetBlockBlobReference(codeUri).DownloadToStream(codeContent);
codeContent.Position = 0;
Process p = new Process();
Now I want to run the executable I've downloaded. I guess that I need to use a Process for that, I just don't know how. can anyone please help?
Thanks in advance
Upvotes: 2
Views: 877
Reputation: 32037
Something like this should do. Pass your blob as the first parameter and the local file path as the second:
public static void RunBlob(ICloudBlob blob, string targetFilePath) {
using (var fileStream = File.OpenWrite(targetFilePath)) {
blob.DownloadToStream(fileStream);
}
var process = new Process() {StartInfo = new ProcessStartInfo(targetFilePath)};
process.Start();
process.WaitForExit(); // Optional
}
Upvotes: 2