0
在我的Windows Mobile應用程序中,我試圖編寫帶有邊界的視頻文件。 如果我把邊界我接收協議例外,但如果我不使用任何邊界它工作正常。ProtocolViolation例外請求在Windows Mobile 6.5中的stream.write()
下面是我的代碼
Stream requestStream = request.GetRequestStream();
byte[] boundaryData = System.Text.Encoding.ASCII.GetBytes(twoHyphens+boundary+lineEnd);
byte[] boundaryData1 = System.Text.Encoding.ASCII.GetBytes(twoHyphens + boundary + twoHyphens + lineEnd);
String headertemp = "Content-Disposition: form-data; name=\"uploadedfile\";filename=\""+ GetCamera.videoFilePath+ "\""+ lineEnd;
byte[] headerData = System.Text.Encoding.ASCII.GetBytes(headertemp);
byte[] lineend = System.Text.Encoding.ASCII.GetBytes(lineEnd);
requestStream.Write(boundaryData, 0, boundaryData.Length);
requestStream.Write(headerData, 0, headerData.Length);
requestStream.Write(lineend, 0, lineend.Length);
using (Stream video = File.OpenRead(GetCamera.videoFilePath))
{
byte[] buffer = new byte[1024];
while ((bytesRead = video.Read(buffer, 0, buffer.Length)) > 0)
{
requestStream.Write(buffer, 0, bytesRead);
}
}
requestStream.Write(lineend, 0, lineend.Length);
requestStream.Write(boundaryData1, 0, boundaryData.Length);
requestStream.Close();
requestStream.Dispose();
請幫我解決這個問題。
請轉發您的寶貴建議。