解决方案 »

  1.   

    把路径配置到web.config里
    读写文件前,先从web.config里读出配置的路径...
      

  2.   

    ~\UploadFile\  变成物理路径,需要使用Server.MapPath详见:
    http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath(v=vs.110).aspx
      

  3.   


    我这样用  srcFileName = HttpContext.Current.Server.MapPath("~/UploadFile/“+xxx.doc);
    在本机上是可以用,但发布后,其他机子上却访问不到,其他机子上传文件到服务器,也上传不上去,本机上测试都没问题,不知道怎么回事啊?
      

  4.   

    找到问题出错地方了,
            object Nothing = System.Reflection.Missing.Value;
            
            object format = Word2.WdSaveFormat.wdFormatDocument;
            Word2.Application wordApp = new Word2.Application();  //这句话就出问题了,应该是其他电脑没有访问服务器的Word的权限,
    其他电脑输出出错信息如下图:
               srcFileName = HttpContext.Current.Server.MapPath("~/UploadFile/han.dotx"); //[路径需要按实际情况修改]     
              
                Word2.Document wordDoc2 = wordApp.Documents.Open(ref srcFileName, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
         目前检测到这句出错,还不晓得路劲那里到底对不对。怎么设置Word,让其他电脑可以访问?