程序运行到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读取中文路径的文件?
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读取中文路径的文件?
{
FileStream fs = File.OpenRead(strfilePath);
}最好不要用中文作为路径,XP下访问没有问题,但在2003下会出错
FileStream fs1 = new FileStream(strfilePath);
你用这样的试试看