TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Duc Le
NA
1
0
Sending file to webpage using Webrequest....
May 17 2007 1:32 AM
Hi all,
II am having problem sending zip file(binary file) using webrequest function from wince5.0 device to a webpage. It works fine for any file with size less than or equal to 1.5kb. Any bigger files, it did not return any error but then the sent files are not stored on the server? They are just lost somewhere.
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();
Reply
Answers (
0
)
help me in my report in c#
Advise on how to study C#