我用
string temp=System.IO.Path.GetTempPath();
 temp=temp.Replace("\"","\\");
它总是提示一大堆错误
我想它是不是出于这样的考虑,怕这个的代替会导致无穷尽的循环代替?
大家是怎么做的呢?
谢谢

解决方案 »

  1.   

    ???
    temp=temp.Replace("\\","\\\\");
      

  2.   

    string [email protected]();
    OK?
      

  3.   

    不行的
    因为temp返回值是C:\Documents and Settings\Administrator\Local Settings\Temp\
    所以就不存在"\\"
    我是想写文件到临时目录下去
      

  4.   

    在c#中\是转义字符,如果要在字符串中使用\字符的话就应改写为"\\"
    所以你你的代码改为temp=temp.Replace("\\","\\\\");就对了
    或者用@取消转义:temp=temp.Replace(@"\",@"\\");也可以
    呵呵,不会死循环的^_^
      

  5.   

    楼主:
    temp=temp.Replace("\"","\\");
    是将"换成\
    如果要将\换成\\的话
    temp=temp.Replace("\\","\\\\");
      

  6.   

    呵呵
    更正:temp=temp.Replace("\"","\\");
    =>
    temp=temp.Replace("\","\\");
    用temp.Replace(@"\",@"\\");
    解决问题了
    谢谢大家的支持
    结帐了