Home » » Save Bytes and Run

Save Bytes and Run

Ever wonder how to save a byte[] array and run it?

This is the code I use to launch a PDF files I have as byte[] arrays.

    // identify temporary file path, save
    var _Folder = System.IO.Path.GetTempPath();
    var _File = string.Format("{0}.PDF"Guid.NewGuid());
    var _Path = System.IO.Path.Combine(_Folder, _File);
    System.IO.File.WriteAllBytes(_Path, bytes);
 

    // let's hope Adobe reader is installed!
    System.Diagnostics.Process.Start(_Path);


0 comments:

Post a Comment

Popular Posts

Powered by Blogger.
.comment-content a {display: none;}