本文介绍了需要支持(小)项目,几个问题,并获得更多......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 你好, 我刚刚开始使用C#,所以我不太了解。 我我为我制作的信息文件创建了一个NFO查看器。 想法如下: - 自定义皮肤(因此没有默认的窗口边框)和自己的按钮; - 一个richtextbox,可转换并显示.nfo文件,自动滚动和循环; - 应用程序启动时的音乐,暂停音乐的按钮(声音关闭); - 作为网站按钮的图片; - 自定义图标; - 我想将它作为一个独立的可执行文件使用,它可以直接运行而且不必查找它需要的文件(音乐文件和nfo,dll'等等) 为此你应该以某种方式使用资源功能。 此时的情况: 我现在有一个运行的应用程序,自定义皮肤/按钮,循环音乐(.it文件), 循环autoscrollin g文本,用户无法与框交互:我不希望他们选择等,没有自定义图标。 (.NFO)文本和.it音乐从默认位置(C:\ Test \ xx.nfo等)加载。 它是使用Visual Studio 2010制作的。我将它设置为x86,因为x64甚至不能在我的笔记本电脑上以调试模式工作。我使用Windows 7旗舰版x64。 我想我的应用程序不能在XP上工作,因为我使用/参考.NET 4,但我希望它至少在W7变种上运行。 问题此时: 1)看来我是少数几个能够运行这个应用程序。 它成功了W7 64位.NET 4.0,W7 32位.NET?,W8 64位.NET 4.5。 我正在尝试找到错误的原因或根本无法运行。 当我导出文件并尝试在其他Pc上运行它们时,没有任何反应或者我收到错误。 NET 4不在PC上。但是当我安装.NET 4时,它会像其他人一样保持沉默。 任何人都可以支持我吗?如果你需要项目,源代码,任何文件,请告诉我! 2)我想合并我的应用程序在项目中需要的文件。 我'我已经阅读了很多关于使用Resources的内容,但是根本无法使用它。 大部分时间都是因为代码中没有引用不同的东西当你错过了''使用xxxx''时你就有了。 如果有人有使用资源的经验并在项目中调用它们,请帮帮我。 如果有些人想要预留一些时间来帮助我,而不是有一个想法的不同的人...那么我可以建立在1的想法,知道什么是已经尝试过我的应用程序如何工作。 希望得到一些帮助,等待回复并感谢那些尝试的人! :)Hello,I''ve just started working with C#, so I don''t have much knowledge.I''m creating a NFO viewer for information files I make.The idea is as following:- A custom skin (so no default windows border) and own buttons on it;- A richtextbox that converts and shows the .nfo file, autoscrolling and looping;- Music on application start, button to pause the music (sound off);- A picture as button to a website;- Custom Icon;- I would like to use it as a standalone executable, which runs directly and doesn''t have to look for the files it needs (the music file and nfo, dll''s? etc.)For this you should use the resources functionality somehow.The situation at this point:I now have an application that runs, custom skin/button, looping music (.it file),looped autoscrolling text, users can''t interact with the box: I don''t want them to select etc, NO custom icon. The (.NFO) text and .it music are loaded from a default location (C:\Test\xx.nfo etc.).It''s made using Visual Studio 2010. I set it for x86, as x64 didn''t even work in debug mode on my laptop. I use Windows 7 Ultimate x64.I guess my application won''t work on XP because I use/refer to .NET 4, but I want it to run at least on the W7 variants.Problems at this time:1) It seems I''m one of the few that are able to run this application.It succeeded on W7 64 bits .NET 4.0, W7 32 bits .NET?, W8 64 bits .NET 4.5.I''m trying to find the cause of the error or not being able to run at all.When I export the files and try to run them on other Pc''s, nothing happens or I get an error that .NET 4 isn''t on the Pc. But when I install .NET 4, it keeps silent like the rest.Can anyone support me with this? If you need the project, sourcecode, any files, just let me know!2) I want to merge the files my application needs in the project itself.I''ve read a lot about using Resources, but couldn''t get it to work at all.Most of the time it''s because there''s no referrence for different things in the code, which you have when you miss the ''using xxxx'' that''s needed.If anyone has experience with using resources and calling them within the project, help me out.If some people want to reserve some time to help me out, instead of different people with 1 idea... Then I can build on the ideas from 1, that knows what has been tried already and how my application works.Hope to get some help, waiting for responses and thanks for those who try! :)推荐答案var pict = Resource_Manager.picture; // return a bitmap in my case 方法#2: 将您的文件添加到您的项目中。在您的文件上,打开属性,并将buildaction设置为embedded resource并复制到输出目录以复制如果更新 在您的代码中:Method #2:add your file to your project. on your file, open properties, and set "buildaction" to "embedded resource" and "copy to output directory" to "copy if newer"in your code:string path;// if the file is at the root of your project, the path will be : var path = "mynamespace.document.docx"// if it is in a directory named "resources_directory", the path will be : var path = "mynamespace.resources_directory.document.docx"using (var stream = assembly.GetManifestResourceStream("path")){ // do whatever you want with it} 如果是一个,文件将在dll中,在案例2中,文件将站在dll旁边。 希望它有所帮助。in case one, files will be in the dll, and in case 2, files will stand next to the dlls.hope it helps.Image myImageInResource = Properties.Resources.MyImage;string myStringInResource = Properties.Resources.MyString1;... 此文件中资源的全名将为: NamespaceOfYourProject.Properties.Resources.ResourceName 通常,NamespaceOfYourProject在代码中默认使用,你可以省略它。 讨论之后以及使用IrrKlang库资源的具体问题 我成功尝试了这段代码:The full name of a resource in this file will be :NamespaceOfYourProject.Properties.Resources.ResourceNameusually, NamespaceOfYourProject is used by default everywhere in your code, and you can ommit it.After Discussion and your specific problem of using resource with the IrrKlang libraryI successfully tried this code:// First of All create the Sound Engine from IrrKlang libraryIrrKlang.ISoundEngine engine = new IrrKlang.ISoundEngine();// Create a sound source from a file in resource with a name and file extensionIrrKlang.ISoundSource source = engine.AddSoundSourceFromMemory(Properties.Resources.test, "test.mp3");// Play the sound using the source object referenceengine.Play2D(source,false,false,false);// Wait 5sSystem.Threading.Thread.Sleep(5000);// Stop the Soundengine.StopAllSounds();// Restart the Sound using its nameengine.Play2D("test.mp3");// Wait 5sSystem.Threading.Thread.Sleep(5000);// Stop the Soundengine.StopAllSounds(); 在这个简短的例子中,你可以看到两种启动声音的方法。 但是你必须提供一个带有原始文件扩展名的名字(在我的例子中) .mp3) 我试过没有它,没有声音(也没有错误)播放。 我认为这是IrrKlang库的限制,你可能会报告这可能是一个错误或可能的改进。我个人认为如果引擎在无法识别声源时报告错误将会很好。 播放声音时,play2D方法总是返回一个ISound对象。In this short example, you can see 2 ways to start the sound.But you must provide a name with its original file extension (in my case ".mp3")I tried without it, and no sound (nor error) was played.I think it is a limitation of this IrrKlang library, you might report this as a bug or a possible amelioration to do. I personnaly think it will be nice if the engine report an error when it did not recognise the sound source.The play2D method always returns an ISound object if playing a sound OR NOT. 这篇关于需要支持(小)项目,几个问题,并获得更多......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 04:44