程序运行到FileStream fs = File.OpenRead(filePath);时出错,filePath为中文路径。出错信息:
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
Step into: Stepping over method without symbols 'System.Web.UI.Page.ProcessRequestMain'
A first chance exception of type 'System.Web.HttpUnhandledException' occurred in System.Web.dll
Step into: Stepping over method without symbols 'System.Web.UI.Page.ProcessRequest'
A first chance exception of type 'System.Web.HttpUnhandledException' occurred in System.Web.dll
Step into: Stepping over method without symbols 'System.Web.UI.Page.ProcessRequest'
Step into: Stepping over method without symbols 'System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute'
Step into: Stepping over method without symbols 'System.Web.HttpApplication.ExecuteStep'
Step into: Stepping over method without symbols 'System.Web.HttpApplication.PipelineStepManager.ResumeSteps'
Step into: Stepping over method without symbols 'System.Web.HttpApplication.BeginProcessRequestNotification'
Step into: Stepping over method without symbols 'System.Web.HttpRuntime.ProcessRequestNotificationPrivate'
Step into: Stepping over method without symbols 'System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper'
Step into: Stepping over method without symbols 'System.Web.Hosting.PipelineRuntime.ProcessRequestNotification'
Step into: Stepping over method without symbols 'System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper'
Step into: Stepping over method without symbols 'System.Web.Hosting.PipelineRuntime.ProcessRequestNotification'
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll请问怎样用FileStream读取中文路径的文件?

解决方案 »

  1.   

    这些信息很难判断哪里有问题,最好提供更多上文。跟踪下filePath的内容是什么!
      

  2.   

    strfilePath = Server.MapPath(strfilePath);if(File.Exists(strfilePath))
    {
        FileStream fs = File.OpenRead(strfilePath);
    }最好不要用中文作为路径,XP下访问没有问题,但在2003下会出错
      

  3.   

    确保英文可以。他的上文是从web.config取得数据库连接字串,就一句话,我跟踪的时候是从FileStream这句话跳出来的。跟踪的时候filePath为C:\\user\\desktop\\新建文件夹\\大螺旋星系123.jpg,文件是我用文件选择控件从对话框里选的,肯定存在。
      

  4.   

    另外,我按照楼上(hujun1024)的建议加入strfilePath = Server.MapPath(strfilePath); 跟踪时运行到此处就出错跳出。
      

  5.   

    strfilePath = Server.MapPath(strfilePath); 
    FileStream fs1 = new FileStream(strfilePath);
    你用这样的试试看