Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 401317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:01:23+00:00 2026-05-12T17:01:23+00:00

I am using c# .net compact framework 3.5 and I want to convert a

  • 0

I am using c# .net compact framework 3.5 and I want to convert a video file to byte array so that I may upload it on the server.

In the similar manner I am doing the image uploading which is getting the success result.

HttpWebRequest request; 
request.ContentType = "image/jpeg";
request.ContentLength = byteArray.Length;
request.Method = "PUT";

imageToByteArray(img).CopyTo(byteArray, 0);
using (Stream requestStream = request.GetRequestStream())
{
  requestStream.Write(byteArray, 0, (int)Fs.Length);
  requestStream.Flush();
  requestStream.Close();
}


public byte[] imageToByteArray(Image imageIn)
{
  MemoryStream ms = new MemoryStream();
  imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
  return ms.ToArray();
}

How to do this for the video files?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:01:23+00:00Added an answer on May 12, 2026 at 5:01 pm

    You should copy the stream one block at a time instead of reading the entire file into an array. Otherwise, you’ll use a potentially very large amount of memory as video files can grow quite big.

    For example:

    HttpWebRequest request; 
    request.Method = "PUT";
    
    using(Stream requestStream = request.GetRequestStream())
    using(Stream video = File.OpenRead("Path")) {
        byte[] buffer = new byte[4096];
    
        while(true) {
            int bytesRead = video.Read(buffer, 0, buffer.Length);
    
            if (bytesRead == 0) break;
            requestStream.Write(buffer, 0, bytesRead);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to centre a popup form launched using Form.ShowDialog() in .NET Compact Framework.
I'm writing my first Windows CE app using the .NET Compact Framework v3.5. I
Hi*, I am using the .NET Compact framework Remote Performance Monitor from the .net
Unfortunately, there is no Semaphore in System.Threading when using the .NET Compact Framework. I'm
I want to downgrade a Windows Mobile application made with .Net Compact Framework 3.5
Using .NET 1.1, I have a DataGrid that contains three columns for each row.
I am using .NET Remoting. My server/hoster is a Windows Service. It will sometimes
I'm using .NET 3.5. I have two string arrays, which may share one or
I need to display the .NET Compact Framework version number on the screen. I
I have a DataGrid that is using a DataReader as its datasource. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.