如何删除特定点的字符

编程入门 行业动态 更新时间:2024-10-25 19:37:41
本文介绍了如何删除特定点的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用文件上传和服务器上保存的照片上传照片,我也在数据库中保存了图像路径。我想使用数据库中的路径检索将图像绑定到图像控件。 以下是检索的路径。 D:\ TFS \User \ Tech.Apps.Ever.Web \ Tech.Apps.Ever.Web \ Doctor \ DOCUMENTS\1326 \照片\ Pengengins.jpg i想删除一个字符串D:\ TFS \User\Tech.Apps.Ever.Web \ Tech。 Apps.Ever.Web \ 之后我想使用剩余路径绑定图像,即Doctor \DOCUMENTS \1326 \Photograph\Penguins。 JPG。请帮我解决我的问题。 谢谢 Manohar

解决方案

string test = @ D:\ TFS \ User.Tech.Apps.Ever.Web \ Tech.Apps.Ever.Web \ Doctor \ DOCUMENTS\1326 \ Photograph \ Penguins.jpg; int index = test.IndexOf( 医生); string sub = test.Substring(index,test.Length - index); MessageBox.Show(sub);

那个

string notSoLongPath = givenPath.SubString(( @ D:\ TFS \ User\Tech.Apps.Ever.Web\Tech.Apps.Ever.Web\)。长度);

它使用子串 [ ^ ]提取字符串一部分的方法。要知道哪个部分, String.Length [ ^ ]属性可以传递给定字符串的长度,在这种情况下是硬编码的字符串文字。 请记住,一般来说,对任何路径进行硬编码都不是一个好主意。相反,将路径存储在应用程序的资源中。

您好, 试试这个 string s = @ d:\TFS\User\Tech.Apps.Ever.Web\Tech.Apps.Ever.Web\Doctor\DOCUMENTS\1326\Photograph\Penguins.jpg; s = s.Replace( @ D:\ TFS \ User.\\ Tech.Apps.Ever .Web\Tech.Apps.Ever.Web \, ) ;

希望有所帮助。

I am upload photograph using file upload and saved photo in server and i also saved image path in database. i want to bind image to image control using path retrieve from database. following is the path which is retrieve. "D:\TFS\User\Tech.Apps.Ever.Web\Tech.Apps.Ever.Web\Doctor\DOCUMENTS\1326\Photograph\Penguins.jpg" i want to remove a string "D:\TFS\User\Tech.Apps.Ever.Web\Tech.Apps.Ever.Web\" after that i want to bind image using remaining path i.e. "Doctor\DOCUMENTS\1326\Photograph\Penguins.jpg". please help me to solve my isssue. Thanks Manohar

解决方案

string test=@"D:\TFS\User\Tech.Apps.Ever.Web\Tech.Apps.Ever.Web\Doctor\DOCUMENTS\1326\Photograph\Penguins.jpg"; int index=test.IndexOf("Doctor"); string sub = test.Substring(index, test.Length - index); MessageBox.Show(sub);

How about that one

string notSoLongPath = givenPath.SubString( (@"D:\TFS\User\Tech.Apps.Ever.Web\Tech.Apps.Ever.Web\").Length );

It uses the Substring[^] method to extract a portion of a string. To know what portion, the String.Length[^] property can deliver the length of a given string, in this case of a hard-coded string literal. Remember that in general, hard-coding any paths is not a good idea. Instead, store the path in your application's resources.

Hi, Try this

string s = @"D:\TFS\User\Tech.Apps.Ever.Web\Tech.Apps.Ever.Web\Doctor\DOCUMENTS\1326\Photograph\Penguins.jpg"; s = s.Replace(@"D:\TFS\User\Tech.Apps.Ever.Web\Tech.Apps.Ever.Web\", "");

Hope it helps.

更多推荐

如何删除特定点的字符

本文发布于:2023-07-11 12:05:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093996.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!