Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string[] files = new string[2] { @textBox1.Text, @textBox2.Text };

            WaveIO wa = new WaveIO();
            wa.Merge(files, @textBox3.Text);

            FileStream fs = new FileStream(textBox3.Text, FileMode.Open, FileAccess.Read);
            System.Media.SoundPlayer sp = new System.Media.SoundPlayer(fs);
            sp.Play();
        }
Ejemplo n.º 2
0
        public JsonResult Upload()
        {
            UploadManager uploadManager = new UploadManager();
            try
            {
                var folder = Server.MapPath("~/" + "Files");
                //string fileSuffix = uploadManager.GetTimestamp(DateTime.Now);
                var fileName = Request.Form["fileName"];
                var file = Request.Files["blob"];
                string filePath = Path.Combine(folder, fileName+".wav");

                string outFilePath = Path.Combine(folder, fileName +"o"+ ".wav");
                //File not exist, write it

                if (!System.IO.File.Exists(filePath))
                {
                    file.SaveAs(filePath);
                }
                else
                {
                    string tempFile = Path.Combine(folder, fileName+"-temp" + ".wav");
                    file.SaveAs(tempFile);
                    string[] filesToMerge = new string[2] {filePath,tempFile};
                    //string[] filesToMerge = new string[1] {tempFile };

                    using (WaveIO wa = new WaveIO())
                    {
                        wa.Merge(filesToMerge, outFilePath);

                        //Append new file with exising file
                        //wa.Append(filePath, tempFile);

                        System.IO.File.Delete(filePath);
                        System.IO.File.Delete(tempFile);
                        System.IO.File.Move(outFilePath, filePath);
                    }
                }

                //var blob = Request.Form["blob"];

                //Request.SaveAs(Server.MapPath("~/" + "Files/" + fileSuffix + ".wav"), false);
                //uploadManager.Upload(Request.Files, folder, fileSuffix);

                return this.Json(new { Success = true, Status = "Uploaded Successfully" });
            }
            catch (Exception ex)
            {
                Response.StatusCode = 500;
                return Json(new { Success = true, Status = "Something went wrong, Please try again." });
            }
        }