[英]How do I access a file path in Blazor?
I added a file to我添加了一个文件
wwwroot/assets wwwroot/资产
the file is called zip.csv该文件名为zip.csv
private const string fileName = "zip.csv";
private const string filePath = "/assets/";
In my method,在我的方法中,
var strLines = File.ReadLines(filePath + fileName);
I am getting a crash (log below)我崩溃了(下面的日志)
blazor.webassembly.js:1 System.IO.DirectoryNotFoundException: Could not find a part of the path "/assets/zip.csv".
I can navigate to http://localhost:5000/assets/zip.csv and download the file我可以导航到 http://localhost:5000/assets/zip.csv 并下载文件
Clientside Blazor is running in the same sandbox as javascript.客户端 Blazor 与 javascript 在同一个沙箱中运行。 To interact with the user's file system, use the HTML standard for accessing the file system, eg with this Blazor wrapper .
要与用户的文件系统交互,请使用 HTML 标准来访问文件系统,例如使用此Blazor 包装器。
Maybe localStorage is sufficient ?也许 localStorage 就足够了? Check this Blazor package to use it
检查这个Blazor 包以使用它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.