路径转为转义字符串

来源:互联网 发布:软件ui设计教程 编辑:程序博客网 时间:2024/06/10 22:26
eg: 将路径"C:\dir.txt"转为"C:\\dir.txt\0"
CString strpath="C:\dir.txt";  //unicode版本 CString strpath=L"C:\dir.txt";或者CString strpath=_T("C:\dir.txt");
strpath.Replace("\\","\\\\");   //strpath="C:\\dir.txt"; 
strpath+="\0";                    //strpath="C:\\dir.txt\0"; 
 
扩展:C#里 @代表后面字符串是转义字符串,strpath.Replace(@"\\",@"\\\\");  
string str=@"C:\dir.txt";  的结果为string str="C:\dir.txt"; 
string str=@"C:\\dir.txt";  的结果为string str="C:\dir.txt"; 
0 0
原创粉丝点击