日期:2014-05-18  浏览次数:20423 次

孟子,思归请进来看看!一个跨服务器读取文件,很难搞且大家都有可能碰到的问题。
环境:    
我有两台服务器:A、B服器    
1、首先在B服器上共享一个文件夹为share;    
2、其次在A服器上用映射的方式,创建一个G:盘;    
3、接着写一个程序读取G:盘里的文件名;    
4、在A服器上建一个站点,将其发布;    
 
问题:    
1、通过IIS发部布的站点访问,就会出现在无法找到G盘的错误提示;    
2、如果是在VS2005上直接调试,不会出现在问题;    
 
我试过的方法:    
  我估计是由于IIS的权限不够才会出现这种问题,可郁闷的是我试了N种法,都没有能搞定,所以才来求助高手!(分数不是问题,不够再加!)    
 
程序:    
                              string     m_strPhysicsPath     =     "g:/ ";    
                              protected     void     Button1_Click(object     sender,     EventArgs     e)    
                              {    
                                              string     currentdir     =     m_strPhysicsPath;         //搜索的目录        
                                              if     (currentdir[currentdir.Length     -     1]     !=     '\\ ')     //非根目录        
                                                              currentdir     +=     "\\ ";    
                                              DataTable     Dt     =     FineFistTable(currentdir);    
                                              GridView1.DataSource     =     Dt;    
                                              GridView1.DataBind();    
             
                              }    
 
                              protected     DataTable     FineFistTable(string     m_strPath)    
                              {    
                                              DirectoryInfo     Dir     =     new     Di