Re: Uploading large files from an iPAQ
From: Dan (dan_at_dontspamme.com)
Date: 09/30/04
- Next message: genc ymeri: "Re: how can I extract zip files in C# ???"
- Previous message: Viktor Popov: "DropDownList problem"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 30 Sep 2004 07:35:20 -0400
Thanks Chris. BTW, do you know whether it's a good idea to flush the stream
as I'm writing the HTTP request? I'm worried that, if I don't, the buffer
might start getting big.
"Chris Tacke, eMVP" <ctacke@spamfree-opennetcf.org> wrote in message
news:%23Au$tympEHA.2900@TK2MSFTNGP12.phx.gbl...
> Not really, and it's even harder here becasue the CF is abstracting the
> actual allocation call. If it were me, I'd just chop it into packets
around
> 1k and go that way. Heck, that even provides a progress hook for nice UI
> interaction.
>
> -Chris
>
>
> "Dan" <dan@dontspamme.com> wrote in message
> news:u6%23fhulpEHA.3716@TK2MSFTNGP10.phx.gbl...
> > Is there a way to find out how much memory you're allowed to use before
> > allocating it?
> >
> > "Chris Tacke, eMVP" <ctacke@spamfree-opennetcf.org> wrote in message
> > news:O4hbx8jpEHA.2764@TK2MSFTNGP11.phx.gbl...
> > > CE's memory model doesn't allow you to use all the "free" memory you
see
> > for
> > > heap allocations. Packetize the send.
> > >
> > > -Chris
> > >
> > >
> > > "Dan" <dan@dontspamme.com> wrote in message
> > > news:uCjFddipEHA.3068@TK2MSFTNGP15.phx.gbl...
> > > > I'm trying to upload a large binary file from an iPAQ, but am
getting
> > > > out-of-memory exceptions when I try to convert the byte array
> containing
> > > the
> > > > data to a string in order to include it in the StringBuilder object
> > which
> > > > represents the http (multipart/form-data mimetype) request. The
code
> > I'm
> > > > using to read and convert the data is below, and the exception
occurs
> in
> > > > ascii.GetString. The file is about 9mb, and I've got plenty of free
> > > memory
> > > > (according the system monitor in the iPAQ, I've got 38.64MB free
> > storage,
> > > > and 61.85MB free program memory). Does anyone have any suggestions?
> > > > Thanks...Dan
> > > >
> > > > try
> > > > {
> > > > fs = new FileStream(m_FileName, FileMode.Open, FileAccess.Read);
> > > > r = new BinaryReader(fs);
> > > > if (fs.Length > int.MaxValue)
> > > > throw new Exception("The ServletRequest library currently will
> not
> > > > upload files greater than " + int.MaxValue + " bytes. " + m_FileName
+
> "
> > > > contains " +
fs.Length
> +
> > "
> > > > bytes.");
> > > > byte[] fileContent = r.ReadBytes((int) fs.Length);
> > > > ASCIIEncoding ascii = new ASCIIEncoding();
> > > > return ascii.GetString(fileContent, 0, fileContent.Length);
> > > > }
> > > > catch (Exception e)
> > > > {
> > > > throw new Exception("Error retrieving filecontent from " +
> > m_FileName,
> > > > e);
> > > > }
> > > >
> > > >
> > >
> > >
> >
> >
>
>
- Next message: genc ymeri: "Re: how can I extract zip files in C# ???"
- Previous message: Viktor Popov: "DropDownList problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|