将WAV文件保存到磁盘

时间:2021-11-27 09:55:08

This is a web service call which I wrote that is intended to receive a WAV file via a POST and store it in the web-app server's local file system (IIS). Is there a simple method to store the file and if so would someone be so kind as to provide a C# example?

这是我写的一个Web服务调用,旨在通过POST接收WAV文件并将其存储在Web应用服务器的本地文件系统(IIS)中。有没有一种简单的方法来存储文件,如果是这样,有人会如此善良以提供一个C#示例?

2 个解决方案

#1


You'll need to have write access to the directory you want to save to.

您需要具有要保存到的目录的写入权限。

Make a FileUpload control, then call its SaveAs method in a postback.

创建一个FileUpload控件,然后在回发中调用其SaveAs方法。

#2


If you're writing a REST service, use the following code:

如果您正在编写REST服务,请使用以下代码:

Request.Files[0].SaveAs(/* some file path */);

Either way, be aware of the security issues - make sure the filename has a .wav extension and don't trust the file to be correct.

无论哪种方式,请注意安全问题 - 确保文件名具有.wav扩展名,并且不相信文件是正确的。

#1


You'll need to have write access to the directory you want to save to.

您需要具有要保存到的目录的写入权限。

Make a FileUpload control, then call its SaveAs method in a postback.

创建一个FileUpload控件,然后在回发中调用其SaveAs方法。

#2


If you're writing a REST service, use the following code:

如果您正在编写REST服务,请使用以下代码:

Request.Files[0].SaveAs(/* some file path */);

Either way, be aware of the security issues - make sure the filename has a .wav extension and don't trust the file to be correct.

无论哪种方式,请注意安全问题 - 确保文件名具有.wav扩展名,并且不相信文件是正确的。