can any one help me,
my string is as folllows
i want last "IMAGEPDF" should be Replaced with "PDF".
Thanks&Regards,
Chetan.k
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Posted Jan 20, 2012, 10:01 AM
Chetan koralliPosted Jan 23, 2012, 12:09 AM
Rashed MohammadPosted Jan 20, 2012, 10:40 AM
Here is the full code. This will replace "IMAGEPDF" by "PDF" (or anything instead of "PDF")
using System;
class StringHandle
{
static void Main()
{
string pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001";
string repStr = "IMAGEPDF";
int idx = pdfPath.LastIndexOf(repStr);
int length = repStr.Length;
pdfPath = pdfPath.Remove(idx, length);
pdfPath = pdfPath.Insert(idx, "PDF");
Console.WriteLine(pdfPath);
}
}
First this removes the last "IMAGEPDF" and then it is replaced by "PDF". You can test it by any string to replace "IMAGEPDF".
jit sunPosted Jan 20, 2012, 10:33 AM
string pdfPath = @" \\fs09\data22\IMAGEPDF\Production\69273\IMAGEPDF\001";
pdfPath = pdfPath.Replace("IMAGEPDF", "PDF");
i think it helps
jitendra