将 WAV 文件保存到磁盘

发布于 2024-07-26 11:58:52 字数 118 浏览 1 评论 0原文

这是我编写的一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷鸟归林 2024-08-02 11:58:52

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

创建一个 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.

独闯女儿国 2024-08-02 11:58:52

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

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

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文