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

  • Home
  • SEARCH
  • 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 8762757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:36:47+00:00 2026-06-13T15:36:47+00:00

I have met an issue regarding the casting type from HttpInputStream to FileStream. How

  • 0

I have met an issue regarding the casting type from HttpInputStream to FileStream.

How I did ?

I have a HttpPostedFileBase object and I want to have FileStream.

I wrote:

public void Test(HttpPostedFileBase postedFile) {
  FileStream fileStream = (FileStream)(postedFile.InputStream); // throw exception

  FileStream anotherFileStream = postedFile.InputStream as FileStream; // null
}

I tried also

public void Test(HttpPostedFileBase postedFile) {
  Stream stream = postedFile.InputStream as Stream;

  FileStream myFile = (FileStream)stream;

}

But no success.

Why at postedFile.InputStream comes HttpInputStream type ?

And how could I solve this issue ?

Thanks

  • 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-06-13T15:36:50+00:00Added an answer on June 13, 2026 at 3:36 pm

    The stream that you get from your HTTP call is read-only sequential (non-seekable) and the FileStream is read/write seekable. You will need first to read the entire stream from the HTTP call into a byte array, then create the FileStream from that array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some MET data I want to validate which would look something like
I have this method . The issue is that when this condition is met
I've met an issue at attempt to request data from MySql database. For instance:
I met an interesting issue about C#. I have code like below. List<Func<int>> actions
I have met this strange issue. Why is so?! Should it be so?
I have been developing an user interface with Java Swing, and I have met
I met strange problem. I have never work with Devise gem before. So, i
I have some logic in before_save whereby (only) when some conditions are met I
I've met a lot of developers that swear by tagging gits. Personally, I have
have written this little class, which generates a UUID every time an object of

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.