开发者

Check if a file exist in the Server in ASP.NET

开发者 https://www.devze.com 2022-12-20 10:25 出处:网络
string jSFile = ResolveUrl(\"~/MyProject/JavaScripts/dir/test.js\"); if (!System.IO.File.Exists(jSFile))
        string jSFile = ResolveUrl("~/MyProject/JavaScripts/dir/test.js");
        if (!System.IO.File.Exists(jSFile))
        {
           ...
        }

This code doesn't work and I guess it's the jSFile that doesn't work well with the IO.File.Exists but I know the jSFile has a valid path because when I use few line later

Page.ClientScript.RegisterClientScriptInclude("myfile",jS开发者_开发知识库File); 

it does attach the JavaScript file to the ASPX and all work fine.

Any idea of how to check if the file exist?


if (!System.IO.File.Exists(Server.MapPath(jSFile)))
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号