Click here to Skip to main content
15,939,960 members
Home / Discussions / C#
   

C#

 
QuestionMigrating C# desktop application to Windows 10 Pin
UnlockSecrets4WeightLoss19-May-16 19:19
UnlockSecrets4WeightLoss19-May-16 19:19 
AnswerRe: Migrating C# desktop application to Windows 10 Pin
Richard MacCutchan19-May-16 21:25
mveRichard MacCutchan19-May-16 21:25 
AnswerRe: Migrating C# desktop application to Windows 10 Pin
Richard Deeming20-May-16 1:47
mveRichard Deeming20-May-16 1:47 
QuestionBuild navigation with routed URL in ASP.NET MVC Pin
Member 1204569219-May-16 19:16
Member 1204569219-May-16 19:16 
AnswerRe: Build navigation with routed URL in ASP.NET MVC Pin
Richard MacCutchan19-May-16 21:24
mveRichard MacCutchan19-May-16 21:24 
QuestionASP.NET MVC. Specific URL for partial views Pin
Member 1204569219-May-16 14:02
Member 1204569219-May-16 14:02 
AnswerRe: ASP.NET MVC. Specific URL for partial views Pin
Richard MacCutchan19-May-16 21:23
mveRichard MacCutchan19-May-16 21:23 
QuestionHow can I download a picture in powershell and display it in C#? Pin
turbosupramk319-May-16 10:34
turbosupramk319-May-16 10:34 
I've tried code similar to what is below, I keep getting an error that says a parameter is missing and when I trace the error it appears the parameter name is "message" and it is blank.

How can I download an image in powershell, keep it in memory (not save it to a file) and then display it in a picturebox in c#?

I see this error mentioned 100's of times on the net and no one has an answer?


[code]
C#
byte[] pictureByteArray = new byte[0];
            object pictureObject = new object();
            Collection<PSObject> results = powershellExchange.Invoke();
            foreach (PSObject result in results)
            {
                //MessageBox.Show(result.Properties["PictureData"].ToString());
                pictureObject = (result.Properties["PictureData"].Value);
                pictureByteArray = Encoding.ASCII.GetBytes(result.Properties["PictureData"].ToString());
                //pictureByteArray = BinaryReader
                
                
            }

            byte[] originalCoverData;
            BinaryFormatter bf = new BinaryFormatter();
            using (var ms = new MemoryStream())
            {
                bf.Serialize(ms, pictureObject);
                originalCoverData = ms.ToArray();
            }

            //http://stackoverflow.com/questions/3801275/how-to-convert-image-in-byte-array/16576471#16576471


            
            //string imageUrl = "http://www.gazzetta.it/Media/Foto/2007/04/17/1900384--346x212.jpg";

            //originalCoverData = new System.Net.WebClient().DownloadData(imageUrl);
            Image x = null;
            x = byteArrayToImage(originalCoverData);

            System.IO.MemoryStream stream = new System.IO.MemoryStream(originalCoverData);
            
            

            pbxDisplayPicture.Image = x;

            System.Drawing.Image img2 = System.Drawing.Image.FromStream(stream);

            pbxDisplayPicture.Image = img2;


[/code]

[code]
C#
public Image byteArrayToImage(byte[] byteArrayIn)
        {
            using (MemoryStream mStream = new MemoryStream(byteArrayIn))
            {
                return Image.FromStream(mStream);
            }
        }


[/code]
AnswerRe: How can I download a picture in powershell and display it in C#? Pin
Richard MacCutchan19-May-16 21:22
mveRichard MacCutchan19-May-16 21:22 
GeneralRe: How can I download a picture in powershell and display it in C#? Pin
turbosupramk324-May-16 9:11
turbosupramk324-May-16 9:11 
QuestionRe: How can I download a picture in powershell and display it in C#? Pin
Richard MacCutchan24-May-16 9:23
mveRichard MacCutchan24-May-16 9:23 
AnswerRe: How can I download a picture in powershell and display it in C#? Pin
turbosupramk324-May-16 10:46
turbosupramk324-May-16 10:46 
GeneralRe: How can I download a picture in powershell and display it in C#? Pin
turbosupramk324-May-16 12:04
turbosupramk324-May-16 12:04 
QuestionIDisposable with COM Pin
hpjchobbes19-May-16 5:13
hpjchobbes19-May-16 5:13 
AnswerRe: IDisposable with COM Pin
Gerry Schmitz19-May-16 5:35
mveGerry Schmitz19-May-16 5:35 
AnswerRe: IDisposable with COM Pin
Dave Kreskowiak19-May-16 5:36
mveDave Kreskowiak19-May-16 5:36 
GeneralRe: IDisposable with COM Pin
OriginalGriff19-May-16 6:16
mveOriginalGriff19-May-16 6:16 
GeneralRe: IDisposable with COM Pin
hpjchobbes19-May-16 7:19
hpjchobbes19-May-16 7:19 
GeneralRe: IDisposable with COM Pin
Dave Kreskowiak19-May-16 7:23
mveDave Kreskowiak19-May-16 7:23 
QuestionEnumResourceLanguages return false for resource type identified by Name Pin
noelblanc18-May-16 10:14
noelblanc18-May-16 10:14 
AnswerRe: EnumResourceLanguages return false for resource type identified by Name Pin
noelblanc18-May-16 22:15
noelblanc18-May-16 22:15 
QuestionDraw 2 lines in a picture box and automatically measure the angle between the line Pin
Shithun NK18-May-16 6:23
Shithun NK18-May-16 6:23 
AnswerRe: Draw 2 lines in a picture box and automatically measure the angle between the line Pin
Pete O'Hanlon18-May-16 6:47
mvePete O'Hanlon18-May-16 6:47 
AnswerRe: Draw 2 lines in a picture box and automatically measure the angle between the line Pin
Matt T Heffron18-May-16 6:54
professionalMatt T Heffron18-May-16 6:54 
AnswerRe: Draw 2 lines in a picture box and automatically measure the angle between the line Pin
OriginalGriff18-May-16 8:10
mveOriginalGriff18-May-16 8:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.