Click here to Skip to main content
15,888,113 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: default gridview listing not showing on page Pin
Richard Deeming23-Apr-15 2:00
mveRichard Deeming23-Apr-15 2:00 
GeneralRe: default gridview listing not showing on page Pin
spirospap23-Apr-15 12:34
spirospap23-Apr-15 12:34 
Questionasp.net, c# Pin
Member 1124536521-Apr-15 16:28
Member 1124536521-Apr-15 16:28 
QuestionASP.Application is giving "An unhandled win32 exception occured in w3wp.exe The Just-In-Time debugger was launched without necessary security permissions" error Pin
indian14320-Apr-15 7:48
indian14320-Apr-15 7:48 
AnswerRe: ASP.Application is giving "An unhandled win32 exception occured in w3wp.exe The Just-In-Time debugger was launched without necessary security permissions" error Pin
indian14320-Apr-15 10:20
indian14320-Apr-15 10:20 
Questionquestion Pin
yousfi amina19-Apr-15 0:20
yousfi amina19-Apr-15 0:20 
AnswerRe: question Pin
Richard Andrew x6419-Apr-15 13:00
professionalRichard Andrew x6419-Apr-15 13:00 
QuestionHow to write to fileOutputStream mapped to physical file c# Pin
Tridip Bhattacharjee17-Apr-15 10:04
professionalTridip Bhattacharjee17-Apr-15 10:04 
here i am trying to save memory stream data into zip files which could be many segment. please see my below code which works fine.
C#
private void button2_Click(object sender, EventArgs e)
        {
            using (SqlConnection sqlConn = new SqlConnection(@"Data Source=BBATRIDIP\SQLSERVER2008R2;Initial Catalog=test;Integrated Security=True"))
            {
                string query = String.Format(@"SELECT [FilePath],[FileName],[FileData] FROM [TestTable]");
                SqlCommand cmd = new SqlCommand(query, sqlConn);
                cmd.Connection.Open();

                System.IO.MemoryStream memStream = null;
                ZipFile zip = new ZipFile();
                zip.MaxOutputSegmentSize = 1024 * 1024; // 1MB each segment size would be
                // the above line would split zip file into multiple files and each file
                //size would be 1MB
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        byte[] data = (byte[])reader["FileData"];
                        memStream = new System.IO.MemoryStream(data);
                        string strFile = reader["FilePath"].ToString() + "\\" + reader["FileName"].ToString();
                        ZipEntry ze = zip.AddEntry(strFile, memStream);
                    }
                }
                zip.Save(@"e:\MyCustomZip.zip");
                memStream.Dispose();
                MessageBox.Show("Job Done");
                // here u can save the zip in memory stream also there is a overload insteaa of saving in HD
            }
        }
i doubt the problem could be that approach stores the zip content in memory. Hence, when the zip content is huge, say exceeds 5 GB then then it crashes. so one guy said write to fileOutputStream mapped to physical file

guide me how to achieve to write to fileOutputStream mapped to physical file ?

i got a write up from this url http://gotoanswer.com/?q=Creating+Zip+file+from+stream+and+downloading+it

see the below code because i doubt probably this way i may be able to write to fileOutputStream mapped to physical file here is the code
C#
MemoryStream stream = new MemoryStream(); 
dt.WriteXml(stream); 
stream.Seek(0,SeekOrigin.Begin);   // <-- must do this after writing the stream!

using (ZipFile zipFile = new ZipFile())
{
  zipFile.AddEntry("Report.xml", "", stream); 
  Response.ClearContent(); 
  Response.ClearHeaders(); 
  Response.AppendHeader("content-disposition", "attachment; filename=Report.zip"); 

  zipFile.Save(Response.OutputStream); 
}

probably this line write to fileOutputStream mapped to physical file, just guide me am i on the right direction?
My Objective

i have to call a web service which will supply large stream of data and i need to save that stream to zip file but zip will not be created at server side rather it will be created at client end. due to large stream of data i need to break the zip file into small segment say 500MB or 1GB. one after one segment will download at client side one by one. when first one will end then user will get a file save dialog to save second segment. when all segment will be completed at client side then client could extract all segment to get one folder which may have many files and sub folder.

just guide me with code sample or suggestion how to achieve it with best performance. i have some constraint like i could not save stream data in multiple segment zip file at server side first and then start the download all segment one by one. so please read my requirement and guide me how to achieve it with best performance for large data.

if anyone observe this line of code
C#
byte[] data = (byte[])reader["FileData"];
memStream = new System.IO.MemoryStream(data);

so i am storing something in memory stream first which is not good when data size would be huge. so guide me how could i achieve my task without using memory stream. rather directly i want to push the stream of data to dotnet zip library which will write each segment to OutputStream one by one.

looking for best guidance. thanks
tbhattacharjee

QuestionRe: How to write to fileOutputStream mapped to physical file c# Pin
jkirkerx17-Apr-15 13:04
professionaljkirkerx17-Apr-15 13:04 
AnswerRe: How to write to fileOutputStream mapped to physical file c# Pin
Tridip Bhattacharjee18-Apr-15 7:48
professionalTridip Bhattacharjee18-Apr-15 7:48 
AnswerRe: How to write to fileOutputStream mapped to physical file c# Pin
jkirkerx19-Apr-15 12:09
professionaljkirkerx19-Apr-15 12:09 
QuestionMake image appear after div, and next dive appear after image Pin
indian14316-Apr-15 9:29
indian14316-Apr-15 9:29 
AnswerRe: Make image appear after div, and next dive appear after image Pin
jkirkerx16-Apr-15 13:24
professionaljkirkerx16-Apr-15 13:24 
QuestionBulk insert using table value parameter hangs my application Pin
Malikdanish15-Apr-15 21:04
professionalMalikdanish15-Apr-15 21:04 
AnswerRe: Bulk insert using table value parameter hangs my application Pin
jkirkerx16-Apr-15 8:58
professionaljkirkerx16-Apr-15 8:58 
GeneralRe: Bulk insert using table value parameter hangs my application Pin
Malikdanish16-Apr-15 9:04
professionalMalikdanish16-Apr-15 9:04 
GeneralRe: Bulk insert using table value parameter hangs my application Pin
jkirkerx16-Apr-15 10:41
professionaljkirkerx16-Apr-15 10:41 
GeneralRe: Bulk insert using table value parameter hangs my application Pin
Malikdanish16-Apr-15 20:45
professionalMalikdanish16-Apr-15 20:45 
GeneralRe: Bulk insert using table value parameter hangs my application Pin
jkirkerx17-Apr-15 8:02
professionaljkirkerx17-Apr-15 8:02 
GeneralRe: Bulk insert using table value parameter hangs my application Pin
Malikdanish17-Apr-15 18:29
professionalMalikdanish17-Apr-15 18:29 
GeneralRe: Bulk insert using table value parameter hangs my application Pin
jkirkerx19-Apr-15 9:18
professionaljkirkerx19-Apr-15 9:18 
Questionissue wih gridview Pin
Praveen Kandari15-Apr-15 0:20
Praveen Kandari15-Apr-15 0:20 
SuggestionRe: issue wih gridview Pin
ZurdoDev15-Apr-15 3:31
professionalZurdoDev15-Apr-15 3:31 
AnswerRe: issue wih gridview Pin
User 418025410-Jul-15 11:18
User 418025410-Jul-15 11:18 
GeneralRe: issue wih gridview Pin
Praveen Kandari15-Jul-15 19:17
Praveen Kandari15-Jul-15 19:17 

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.