Last post Sep 09, 2008 09:06 AM by mohammedrabeeh
Sep 09, 2008 09:06 AM|mohammedrabeeh|LINK
I am sending audio and video to server using HttpConnection. My problem is I want to save these to audio and video files in server.
I have done this with image
string imgPath = "F:\\Sample.jpg";
System.Drawing.Image img = Bitmap.FromStream(Request.InputStream);
Its working properly. Now i want to do the same with Audio and Video.
I use the following code
StreamReader sr = new StreamReader(Request.InputStream);
string File = sr.ReadToEnd();
int nDex = File.IndexOf('=');
if (nDex != -1) File = File.Remove(0, nDex + 1);
byte ba = HttpUtility.UrlDecodeToBytes(File);
string path = "fd.avi";
string filePath = @"F:\" + path;
FileStream fs = new FileStream(filePath, FileMode.CreateNew);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(ba); bw.Flush(); fs.Close();
But the file is corrupt. I cant read the file. May be i am missing some encoding.
Is there any way to save Request.Inputstream to audio and video files?
Thanks in Advance.