问题描述
大家好,
我有一个名为root的变量,其中包含
(E:\ Web\Websites\fileBrowse \)和然后我有一个名为path
的变量,它使用root,并在其上添加目录(这是一个文件的一部分
浏览器我已经建立)。我试图简单地从路径字符串中删除根字符串
,例如下面:
root = E:\ Web \网站\ fileBrowse \
path = E:\\\\\\\\\\\\\\\\\\\\\\\ " images \"
我正在尝试使用以下代码行来执行此操作:
blah = path。 TrimStart(root.ToCharArray());
这不行。而不是得到images \,我得到了
years\。我已经尝试使用char
数组的开始和结束元素进行修剪,但我仍然得到相同的结果。似乎由于某种原因
\在根的末尾被修剪被视为一个控制
字符,因此也需要程序两个字符im。
有没有人得到任何想法如何阻止这种情况发生?我希望它是'
我想要的简单东西。
任何帮助都会受到赞赏。
Hi all,
I have a variable called root which contains
(E:\Web\Websites\fileBrowse\) and then I have a variable called path
which uses root, and adds directories on to it (this is part of a file
browser i''ve built). I''m trying to simply remove the root string from
the path string, so for example below:
root = E:\Web\Websites\fileBrowse\
path = E:\Web\Websites\fileBrowse\images\
the result I want should be "images\"
I''m attempting to do this using the following line of code:
blah = path.TrimStart(root.ToCharArray());
This isn''t working though. Instead of getting "images\", i''m getting
"ages\". I''ve tried trimming using a start and end element of the char
array but I still get the same result. It seems that for some reason
the "\" which is trimmed at the end of root is taken as a control
character and so takes the proceding two characters too "im".
Has anyone got any idea how to stop this happening? I''m hoping it''s
something simple which i''m overlooking.
Any help would be appreciated.
推荐答案
嗨Augustin,
我不是很擅长VB,所以你能告诉我什么是替换是一个
的方法吗?我可以找到string.Replace。但这只需要2个单一的b
。另外MessageBoax对ASP.Net页面是不可用的呢?
对不起,如果我在这里密集的话。
Hi Augustin,
I''m not very up on VB, so could you tell me what the Replace is a
method of? I can find string.Replace. But that only takes 2 single
chars. Also MessageBoax isn''t availible to ASP.Net pages is it?
Sorry if i''m being dense here.
这篇关于字符串帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!