Hi all ... i have a tricky problem.. cant seem to find a solution to it :
[CODE=cs]
using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Text.Reg ularExpressions ;
namespace ConsoleApplicat ion1
{
class myfunc
{
public string GetFileName(str ing szPath)
{
Regex r = new Regex(@"\w+[.]\w+$+");
return r.Match(szPath) .Value;
}
}
class Program
{
static void Main(string[] args)
{
myfunc a = new myfunc();
string path = "c:\tet\tee\tet e.txt";
string final_path = '@' + path;
Console.WriteLi ne(final_path);
Console.WriteLi ne(a.GetFileNam e(final_path));
Console.ReadLin e();
}
}
}
[/CODE]
the above code gives me folllowing line of output :
@C: et ee ete.txt
ete.txt
what i am trying to do is convert the normal string to verbatim string so that the escape sequences are ignored and the correct file name is outputted ... is this possible ?
ie .. the output shud be :
c:\tet\tee\tete .txt
tete.txt
[CODE=cs]
using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Text.Reg ularExpressions ;
namespace ConsoleApplicat ion1
{
class myfunc
{
public string GetFileName(str ing szPath)
{
Regex r = new Regex(@"\w+[.]\w+$+");
return r.Match(szPath) .Value;
}
}
class Program
{
static void Main(string[] args)
{
myfunc a = new myfunc();
string path = "c:\tet\tee\tet e.txt";
string final_path = '@' + path;
Console.WriteLi ne(final_path);
Console.WriteLi ne(a.GetFileNam e(final_path));
Console.ReadLin e();
}
}
}
[/CODE]
the above code gives me folllowing line of output :
@C: et ee ete.txt
ete.txt
what i am trying to do is convert the normal string to verbatim string so that the escape sequences are ignored and the correct file name is outputted ... is this possible ?
ie .. the output shud be :
c:\tet\tee\tete .txt
tete.txt
Comment