如何返回 C# / ASP.NET Web 应用程序中的完整文件路径?

发布于 2024-08-28 17:12:59 字数 171 浏览 2 评论 0原文

这应该非常简单,但我已经尝试了互联网上发布的许多解决方案,所以我想我应该在这里尝试一下。我有一个 VS 2008 Web 应用程序,我需要从所选文件中捕获完整的文件路径(目录和文件名)。因此,用户选择一个文件,然后单击其中一个按钮,将控制权转移到我的代码进行处理。那么如何获取文件路径呢?我可以获取文件名,但不能获取路径。谢谢!

This should be really simple, but I have tried many solutions posted on the internet so I thought I'd give this a try here. I have a VS 2008 web application that I need to capture the full file path (directories and file name) from the selected file. So user selects a file and then clicks on one of the buttons which transfers control to my code for processing. So how do I get the file path? I can get the file name, but not the path. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

白况 2024-09-04 17:12:59

尝试使用 Server.MapPath。这更适合在 Web 应用程序中使用。

华泰

Try using Server.MapPath. This is much better to use in Web Apps.

HTH

ヤ经典坏疍 2024-09-04 17:12:59
string fullpath = Request.PhysicalApplicationPath;
string fullpath = Request.PhysicalApplicationPath;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文