-1

I Im trying to convener 10GB file in to Byte in asp.net I'm doing this code below:

 if (FileUpload1.FileName != "")
            {        
                Byte[] MediaBytes = new 
  byte[FileUpload1.PostedFile.InputStream.Length];        

            }

there i added FileUpload1 for browse a file of any size 10GB or any. im cant to convert big file in to Byte and save it in to SQL Sever. i also add this code in web.config which help me to to convert 640MB in Byte and code is working with 640MB file i want to convert big size file too in Byte as well. i used a code in web.config that is below for ISS6

<httpRuntime executionTimeout="9999" maxRequestLength="2099999999"/>

and for iss7 i use this extra code in web.config what is below:

<system.webServer>
    <security>
      <requestFiltering>        
        <requestLimits maxAllowedContentLength="1024000000"/>
      </requestFiltering>
    </security>
  </system.webServer>

please help me out how can i convert big files in Byte easily and fast. please give me solution how can i do this.

Vikram
  • 489
  • 3
  • 8
  • 18
  • 2
    You asked the same question here http://stackoverflow.com/questions/17904580/how-to-upload-up-10gb-file-on-asp-net and, as pointed out, you can't use `FileUpload` to upload a 10gb file. – keyboardP Jul 28 '13 at 17:06
  • 1
    Four gig limit? Why do you want to store a file that size in a db anyway? Storing any file in one is not a great idea, 10 gig is well daft. – Tony Hopkinson Jul 28 '13 at 17:10

1 Answers1

1

Here is the code which converts stream to byte. Please continue reading before you use the code.

var file = FileUpload1.PostedFile;
var imgStream = file.InputStream;
var length = file.ContentLength;
var data = new byte[length]; 
imgStream.Read(data, 0, length);

// data is the one you need.

First of all, you should not store large file in database, it'll kill both Web Sever and especially SQL Server.

Instead you should just store file in File System, and keep the file path in database.

This is one of my favorite -

Is it a bad practice to store large files (10 MB) in a database?

Community
  • 1
  • 1
Win
  • 61,100
  • 13
  • 102
  • 181
  • Hi Win i think that is not a bad idea about save file in database and i want to convert file in lag file in Byte. – Vikram Jul 29 '13 at 09:26