如何获取当前文件的虚拟路径!
IServiceProvider provider=(IServiceProvider)HttpContext.Current;
HttpWorkerRequest wr = (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));
string virtual_path =wr.GetFilePath().ToString();
IServiceProvider provider=(IServiceProvider)HttpContext.Current;
HttpWorkerRequest wr = (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));
string virtual_path =wr.GetFilePath().ToString();
本文介绍了一种通过使用 HttpWorkerRequest 对象来获取 ASP.NET 应用中当前文件虚拟路径的方法。此方法首先从当前 HTTP 上下文中获取 IServiceProvider 接口,接着利用此接口获得 HttpWorkerRequest 实例,并最终调用 GetFilePath 方法来获取文件的虚拟路径。
202

被折叠的 条评论
为什么被折叠?



