File.OpenRead()中文路径出错

rollthewong rollthewong 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
程序运行到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读取中文路径的文件?
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
rollthewong
C# 111,129 成员 642,540 内容