p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > C# and C > C# 2005 > C# 2005
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 22nd, 2007, 11:03 PM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Upload zip file (WinCe 5.0) using WebRequest

Hi all,

II am having problem sending zip file(binary file) using webrequest function from wince5.0 device to a webpage. The webpage will accept the stream sent from the device then save it as appropriate file. It works fine for any file with size less than or equal to 1.5kb. Any bigger files, it did not return any error that i can see but then the sent files are just not stored on the server? They are just lost.

And i tried so many ways but still hopeless. can you please help me out.
Here are my code:

FROM WINCE DEVICE:

.............
FileStream fs = null;
WebRequest req = null;
Stream reqst = null;

fs = new FileStream(SourceFilePath, FileMode.Open, FileAccess.Read);
int totalLength = (((int)fs.Length) + 1);
byte[] buffer = new byte[totalLength];

fs.Read(buffer, 0, buffer.Length);

req = WebRequest.Create(GlobalHandler.g_strUploadUrl);
req.Method = "POST";

req.ContentType = "multipart/form-data";
WebHeaderCollection WH = new WebHeaderCollection();
WH.Add("FileName", MyFileName);

req.Headers = WH;

req.ContentLength = buffer.Length;

reqst = req.GetRequestStream(); //add data to request stream
Print("Geting Request Stream");
reqst.Write(buffer, 0, buffer.Length);// (buffer, 0, buffer.Length);
......................................


CODE FROM WEBPAGE:

.................................................. ............
StreamWriter tw = null;
Stream st = null;
FileStream output = null;


Page.Request.ContentType = "multipart/form-data";
string strFileNamePrefix = Page.Request.Headers.Get("FileName");

st = Page.Request.InputStream;

output = new FileStream(System.String.Concat(dirPath, strUnit, "\\", strDirectory, "\\", TimeStampInFileNameFormat(), ".zip"), FileMode.CreateNew);

Byte[] buffer = new Byte[4096];
int byteReads = st.Read(buffer, 0, 4096);
while (byteReads > 0)
{
output.Write(buffer, 0, byteReads);
byteReads = st.Read(buffer, 0, 4096);
}

st.Close();
output.Close();


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload zip file (WinCe 5.0) using WebRequest duclm7 .NET Framework 1.x 0 May 22nd, 2007 11:13 PM
Upload zip file (WinCe 5.0) using WebRequest duclm7 .NET Framework 2.0 0 May 22nd, 2007 11:12 PM
Upload zip file (WinCe 5.0) using WebRequest duclm7 C# 0 May 22nd, 2007 11:11 PM
Upload zip file (WinCe 5.0) using WebRequest duclm7 .NET Web Services 0 May 22nd, 2007 11:02 PM
Zip File Venkatesan General .NET 0 February 3rd, 2007 05:59 AM



All times are GMT -4. The time now is 12:57 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc