将 WAV 文件保存到磁盘
这是我编写的一个 Web 服务调用,旨在通过 POST 接收 WAV 文件并将其存储在 Web 应用程序服务器的本地文件系统 (IIS) 中。 是否有一种简单的方法来存储文件,如果有的话,有人可以提供一个 C# 示例吗?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要对要保存到的目录具有写权限。
创建一个 FileUpload 控件,然后在回发中调用其 SaveAs 方法。
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.
如果您正在编写 REST 服务,请使用以下代码:
无论哪种方式,请注意安全问题 - 确保文件名具有 .wav 扩展名,并且不要相信该文件是正确的。
If you're writing a REST service, use the following code:
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.