Click here to Skip to main content
15,917,628 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionXML Error Pin
kirthikirthi8-Aug-06 11:41
kirthikirthi8-Aug-06 11:41 
AnswerRe: XML Error Pin
Patricker8-Aug-06 12:16
Patricker8-Aug-06 12:16 
QuestionXML Pin
kirthikirthi8-Aug-06 10:04
kirthikirthi8-Aug-06 10:04 
AnswerRe: XML Pin
Mike Ellison8-Aug-06 10:22
Mike Ellison8-Aug-06 10:22 
GeneralRe: XML Pin
kirthikirthi8-Aug-06 10:36
kirthikirthi8-Aug-06 10:36 
GeneralRe: XML Pin
cloudking119668-Aug-06 23:07
cloudking119668-Aug-06 23:07 
GeneralRe: XML Pin
kirthikirthi9-Aug-06 7:52
kirthikirthi9-Aug-06 7:52 
Questionwriting multiple files to a single zip file Pin
jung19758-Aug-06 8:57
jung19758-Aug-06 8:57 
Below code is generating multiple files from the file that the user has uploaded and put the outputs ( multiple text files) to a single file. I am using the NET Zip Library. but, when I run this code, I am getting "size was 1452, but I expected 128028" error on zipos.PutNextEntry(zipentry);

Can you help me to figure this out?

protected void Button1_Click(object sender, EventArgs e)
{

if (FileUpload1.HasFile)
try
{
FileUpload1.SaveAs("C:\\ERAFile\\" +
FileUpload1.FileName);
Label1.Text = "File name: " +
FileUpload1.PostedFile.FileName + "
" +
FileUpload1.PostedFile.ContentLength + " kb
" +
"Content type: " +
FileUpload1.PostedFile.ContentType;
}
catch (Exception ex)
{
Label1.Text = "ERROR: " + ex.Message.ToString();
}
else
{
Label1.Text = "You have not specified a file.";
}




////Find the path/name of the file tha you just uploaded in the server

string filename = "C:\\ERAFile\\" + FileUpload1.FileName;

// string filename = TextBox1.Text;
StreamReader sr = new StreamReader(@filename);

string curDate = DateTime.Now.ToString("yyyyMMddHHmmss");

string strText = sr.ReadToEnd();
sr.Close();

///Generate outputs

ArrayList providers = new ArrayList();

int newPos = strText.IndexOf("~GS");
int curPos = newPos;

string header = strText.Substring(0, newPos);
string footer = "";

while (newPos > 0)
{
newPos = strText.IndexOf("~GS", curPos + 1);

if (newPos > 0)
{
providers.Add(strText.Substring(curPos, newPos - curPos));
}
else
{
int footerPos = strText.IndexOf("~IEA", curPos);
providers.Add(strText.Substring(curPos, footerPos - curPos));
footer = strText.Substring(footerPos);
}

curPos = newPos;
}

string[] arrFooter = footer.Split('*');
string newFooter = arrFooter[0] + "*1*" + arrFooter[2];

int fileCount = 0;


StringBuilder FileList = new StringBuilder();
FileList.Append("The total number of files processed : " + providers.Count + "\r\n");
string filename2 = FileUpload1.FileName.Substring(0, FileUpload1.FileName.Length - 4);

Crc32 crc = new Crc32();

ZipOutputStream zipos = new ZipOutputStream(File.Create(@"C:\ERAFile\"+ filename2 +".zip"));


foreach (string provider in providers)
{
string filename1 = FileUpload1.FileName.Substring(0, FileUpload1.FileName.Length - 4);
fileCount++;
StringBuilder outFile = new StringBuilder();
outFile.Append(header + provider + newFooter);
string fileName = @"C:\ERAFile\" + filename1 + fileCount + curDate + ".txt";

int filesize = outFile.Length;
FileList.Append(fileName + "\r\n");

FileStream fs = File.OpenRead(filename);
byte[] buffer = new byte[outFile.Length];
fs.Read(buffer, 0, buffer.Length);
ZipEntry zipentry = new ZipEntry(filename);
zipentry.Size = fs.Length;
fs.Close();

crc.Reset();
crc.Update(buffer);
zipentry.Crc = crc.Value;
zipos.PutNextEntry(zipentry);
zipos.Write(buffer, 0, buffer.Length);

}

zipos.Finish();
zipos.Close();Cry | :((


Label2.Text = FileList.ToString();
Label2.Visible = true;




}
QuestionHow can I put a text value into Textarea, which is a part of asp-Table? Pin
HilSoft8-Aug-06 8:56
HilSoft8-Aug-06 8:56 
AnswerRe: How can I put a text value into Textarea, which is a part of asp-Table? Pin
bugnuker8-Aug-06 9:36
bugnuker8-Aug-06 9:36 
GeneralRe: How can I put a text value into Textarea, which is a part of asp-Table? Pin
HilSoft8-Aug-06 10:42
HilSoft8-Aug-06 10:42 
QuestionLoop through WebControls and my CMS.... Pin
Kasic Slobodan8-Aug-06 7:54
Kasic Slobodan8-Aug-06 7:54 
AnswerRe: Loop through WebControls and my CMS.... Pin
Ramasubramaniam8-Aug-06 10:52
Ramasubramaniam8-Aug-06 10:52 
GeneralRe: Loop through WebControls and my CMS.... Pin
Kasic Slobodan8-Aug-06 11:27
Kasic Slobodan8-Aug-06 11:27 
GeneralRe: Loop through WebControls and my CMS.... Pin
Kasic Slobodan8-Aug-06 12:53
Kasic Slobodan8-Aug-06 12:53 
QuestionNeed the Information how to link the EPDQ Barclay In ASP.net [modified] Pin
Syed Taqi8-Aug-06 7:38
Syed Taqi8-Aug-06 7:38 
QuestionDataCalendar - Looking for Mike Ellison Pin
bugnuker8-Aug-06 6:41
bugnuker8-Aug-06 6:41 
AnswerRe: DataCalendar - Looking for Mike Ellison Pin
Mike Ellison8-Aug-06 10:26
Mike Ellison8-Aug-06 10:26 
Questionhow i can add sqldataadapter in datagrid by using <b>toolbox(data)</b> Pin
omi988-Aug-06 6:10
omi988-Aug-06 6:10 
AnswerRe: sqldataadapter Pin
Not Active8-Aug-06 7:16
mentorNot Active8-Aug-06 7:16 
AnswerRe: sqldataadapter Pin
Ramasubramaniam8-Aug-06 10:49
Ramasubramaniam8-Aug-06 10:49 
GeneralRe: sqldataadapter Pin
omi989-Aug-06 5:42
omi989-Aug-06 5:42 
GeneralRe: sqldataadapter Pin
Ramasubramaniam9-Aug-06 7:31
Ramasubramaniam9-Aug-06 7:31 
GeneralRe: sqldataadapter Pin
omi9810-Aug-06 2:00
omi9810-Aug-06 2:00 
QuestionNeed Advice - Setting-up .NET for Classic ASP shop Pin
robert1108-Aug-06 6:09
robert1108-Aug-06 6:09 

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.