Environment.CurrentDirectory 这个属性会随着环境的变化而变化,故不要使用。
有两种方式被代替
若是Winform中 用 Application.StartPath代替
若是Web中 用Server.MapPath代替,例如:
string filePath = Server.MapPath(@"~/images/pic1.jpg");
本文讨论了.NET框架中Environment.CurrentDirectory属性的局限性,并提供了两种替代方案:在Winform中使用Application.StartPath,在Web环境中使用Server.MapPath。详细解释了这两种方法的应用场景及示例代码。
Environment.CurrentDirectory 这个属性会随着环境的变化而变化,故不要使用。
有两种方式被代替
若是Winform中 用 Application.StartPath代替
若是Web中 用Server.MapPath代替,例如:
string filePath = Server.MapPath(@"~/images/pic1.jpg");
894

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