日期:2014-05-20  浏览次数:20749 次

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


------解决方案--------------------
filename可以直接用的,不用再加转义符了。
------解决方案--------------------
a = filename 不行吗?

*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)

最新版本:20070130

http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
------解决方案--------------------
例如:(程序在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 );
------解决方案--------------------
string str = "xxx\\yy ";
string str1 =@str;