Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
FileUpload 控件要求我在 SaveAs() 方法中提供根目录。但是,我更希望上传的文件进入一个虚拟目录,例如“~/UserFiles/[username]/[filename]”。有没有办法让我做到这一点?
使用页面 MapPath 方法:-
ctl.SaveAs(MapPath("~/UserFiles/[username]/[filename]"));
不,关键字是要求。下载后,您可以使用脚本复制文件。
有时 MapPath 不能直接访问。
在这种情况下使用
ctl.SaveAs(Server.MapPath("~/UserFiles/[username]/[filename]"));