The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
How create page for uploading files RRS feed

  • Question

  • Hello, please help me. I need use BackgroundFileTransfer to upload large files. How I create PHP or ASP page for saving files? This example dont work for me -

    http://blogs.msdn.com/b/codefx/archive/2012/02/23/more-about-rest-file-upload-download-service-with-asp-net-web-api-and-windows-phone-background-file-transfer.aspx

    and other example I did not find it.

    Sunday, January 12, 2014 5:24 PM

All replies

  • I already have a solution:

     protected void Page_Load(object sender, EventArgs e)
            {
                string path = "path";
                FileStream writeStream = new FileStream(path, FileMode.Create, FileAccess.Write);

                ReadWriteStream(Request.InputStream, writeStream);

                writeStream.Close();
            }

            private void ReadWriteStream(Stream readStream, Stream writeStream)
            {
                int Length = 256;
                Byte[] buffer = new Byte[Length];
                int bytesRead = readStream.Read(buffer, 0, Length);
                // write the required bytes 
                while (bytesRead > 0)
                {
                    writeStream.Write(buffer, 0, bytesRead);
                    bytesRead = readStream.Read(buffer, 0, Length);
                }
                readStream.Close();
                writeStream.Close(); 
            }

    Thank you.. :)

    Sunday, January 12, 2014 9:04 PM