要读取一个文件,假设路径是 
  string s = "c:\a.dat" 或由打开对话框得到的路径
  现在有一个函数要对他进行处理
  public void aaa(string filename)
 {
   // 我想要这样的效果
   string a =@""c:\a.dat"" ;
   但是 a = @+filename 是不行的,应该怎么办?
 }

解决方案 »

  1.   

    filename可以直接用的,不用再加转义符了。
      

  2.   

    a = filename 不行吗?
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 最新版本:20070130http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
      

  3.   

    例如:(程序在2003下測試通過)
    string FilePath = time.Year.ToString() + time.Month.ToString() + time.Date.Day.ToString() + ".txt" ;
    if( !File.Exists( FilePath ) )
    {
           MessageBox.Show( "The log which you choose does not exist!" );
           return ;
    }
    FileStream fs = File.Open( FilePath , FileMode.Open , FileAccess.Read , FileShare.None );
      

  4.   

    string str = "xxx\\yy";
    string str1 =@str;