Monodroid 中的 FileStream 自动出现斜杠
我一直在使用 Monodroid 开发一个项目。我需要使用 FileStream 访问项目中的文件。我将路径写为 FileStream 中的第一个参数,如 FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read) 但两个斜杠自动来自 FileStream,因此路径无效。例如,如果路径是“res/raw/aFile.txt”,则在FileStream方法之后它会变成“//res/raw/aFile.txt”,并且会发生异常。由于异常,我无法拆分并获取有效路径。如何去掉 FileStream 方法自动生成的两个斜杠?
问候。
I have been working on a project using Monodroid. I need to use FileStream to access a file in my project. I write the path as a first argument in FileStream like FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read) but two slashes come automatically from FileStream, therefore the path is not valid. For example, if the path is "res/raw/aFile.txt", after FileStream method it becomes "//res/raw/aFile.txt" and an exception occurs. Because of the exception, I cannot split and get the valid path. How can I get rid of the two slashes that automatically coming from the FileStream method?
Regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您尝试打开原始资源文件,我建议使用 OpenRawResource() 方法改为:
If you're trying to open a raw resource file, I would suggest using the OpenRawResource() method instead: