路径中的非法字符(资源文件的路径) [英] Illegal character in path (of Resources file)

查看:749
本文介绍了路径中的非法字符(资源文件的路径)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows控件库项目(visual studio 2010)。我把编译选项卡作为一个com元素(我使用它作为另一个程序的插件)。

I have a Windows Control Library project (visual studio 2010). I put in the compile tab for it to be a com element (I use it as an addin for another program).

我的问题是以下:
我有一个.cvs文件在我的资源,我用来解析一些主要设置。
读取此文件的代码行在运行插件时出现错误。
代码行:

My question is the following: I have a .cvs file in my resources that I use to parse some main settings. The line of code that reads this file gives an error when I run the addin. code line:

dim reader as new streamReader(My.Resources.standards) 

(文件称为标准)

com元素:

Illegal character in path.

当我测试它作为一个普通的Windows窗体项目时,程序运行得很好。

The program runs nicely when I test it as a normal windows form project.

任何人都知道如何解决这个问题?

Anyone know how to fix this? Or how to do decent debugging when testing com elements.

推荐答案

这与COM没有任何关系,划伤你的问题的原因。显然,您的 My.Resources.standards 属性会返回字符串,而不是流。当你将一个文本文件作为资源添加时,这是很正常的。它使StreamReader尝试使用.cvs资源的内容作为文件的路径在磁盘上打开文件。这当然不会工作。

This does not have anything to do with COM, scratch that as a cause of your problem. Clearly your My.Resources.standards property returns a string, not a stream. Which is pretty normal when you add a text file as a resource. It makes StreamReader try to open a file on disk using the content of the .cvs resource as the path of the file. That will of course not work well.

您可以使用StringReader。或者直接使用返回的字符串。

You could use a StringReader instead. Or just use the returned string as-is.

这篇关于路径中的非法字符(资源文件的路径)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆