string fileName = string.Empty; string savePath = string.Empty; protected void Page_Load(object sender, EventArgs e) { } protected void UploadBtn_Click(object sender, EventArgs e) { savePath = Server.MapPath(".") + "\\TempFiles\\"; if (FileUpload1.HasFile) { fileName = Server.HtmlEncode(FileUpload1.FileName); string extension = System.IO.Path.GetExtension(fileName); if ((extension == ".DSS") || (extension == ".ds2") || (extension == ".dss") || (extension == ".WAV")) { ToWav(fileName, savePath); savePath += fileName; FileUpload1.SaveAs(savePath); UploadStatusLabel.Text = "Your file was uploaded successfully."; } else { UploadStatusLabel.Text = "Your file was not uploaded because " + "it does not have a .dss or .ds2 or .wav extension."; } } } static void ToWav(string filename, string path) { using (DsReader dr = new DsReader(filename)) { IntPtr format = dr.ReadFormat(); using (WaveWriter ww = new WaveWriter(File.Create(path + ".wav"), AudioCompressionManager.FormatBytes(format))) { byte[] data = dr.ReadData(); ww.WriteData(data); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)