[英]Is there something like a Url.Content for local paths?
我喜欢你如何使用Url.Content获取文件的Web服务器路径,是否有本地路径的等价物,例如,如果我想保存文件?
The MapPath
method maps the specified relative or virtual path to the corresponding physical directory on the server. MapPath
方法将指定的相对或虚拟路径映射到服务器上的相应物理目录。 msdn Also look at server.mappath(“.”), server.mappath(“~”), server.mappath(@“\\”), server.mappath(“/”). msdn还要查看server.mappath(“。”),server.mappath(“〜”),server.mappath(@“\\”),server.mappath(“/”)。 What is the difference? 有什么区别?
The Environment.SpecialFolder
enumeration has a selection of special paths you can use, for instance, you could use something like below to get a path to the user's Application Data path: Environment.SpecialFolder
枚举有一系列可以使用的特殊路径,例如,您可以使用类似下面的内容来获取用户的应用程序数据路径的路径:
string appDataPath =
Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"YourCompany\\YourApp");
I usually accomplish this using: 我通常使用以下方法来实现
Server.MapPath(Url.Content("[...]"));
Reggards Reggards
Do you want to get physicalPath? 你想获得physicalPath吗?
Then try: 然后尝试:
string physicalPath = Server.MapPath("/bin");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.