在将文件路径从web.config放入字符串变量之前,在应用程序级别编辑文件路径 [英] Editing the file path at application level before getting it into string variable from web.config

查看:76
本文介绍了在将文件路径从web.config放入字符串变量之前,在应用程序级别编辑文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,从web.config获取文件路径,它在目录之间包含\\,我想在获取应用程序路径的同时使用@替换为\,而无需使用字符串replace().

表示在获取之前在应用程序级别将@动态添加到文件路径,然后该路径将自动替换为\,其中包含\\.

I have a requirement Getting file path from web.config, it contains \\ in between directories, I want to replace those by \ by using @ while getting the path to the application and without using string replace().

Means dynamically adding the @ to file path at application level before getting it, then automatically the path will be replaced by \ where it contains \\.

推荐答案

它在目录之间包含\\
出于什么原因,您想要这个吗? .NET内部,用另一个"\"转义"\".只要您不进行替换或执行诸如split等操作,就不必担心.即使在前端显示它,也将显示正确的结果.

此外,仅添加AFAIK,就不能将@动态添加到选择的路径.
it contains \\ in between directories
For what reason, you want this? .NET internally, escapes ''\'' by another ''\''. As long as you are not replacing or doing any operation like split or so, you should not worry about it. Even display of it on frontend will show correct result.

Further, just to add, AFAIK, you cannot add @ dynamically to a path picked.


这篇关于在将文件路径从web.config放入字符串变量之前,在应用程序级别编辑文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆