I have a problem with threads for embedded resources. Most online samples show paths that can be directly translated by changing the slash of the path to a point for the source (MyFolder / MyFile.ext becomes MyNamespace.MyFolder.MyFile.ext). However, when the folder has a period in the name and when special characters are used, manually obtaining the resource name does not work. I am trying to find a function that can convert the path to a resource name, since Visual Studio renames them at compilation time.
These names are from the solution ...
- Contents /jQuery.UI-1.8.2/jQuery.UI.css
- Scripting / jQuery -1.5.2 / jquery.js
- Scripts /jQuery.jPlayer-2.0.0/jQuery.jPlayer.js
- Scripts /jQuery.UI-1.8.2/jQuery.UI.js
... change to these names in resources ...
- Content.jQuery.UI_1._8._2.jQuery.UI.css
- Scripts.jQuery_1._5._2.jQuery.js
- Scripts.jQuery.jPlayer_2._0._0.jQuery.jPlayer.js
- Scripts.jQuery.UI_1._8._12.jQuery.UI.js
Slashes translate to points. However, when a dot is used in the folder name, the first dot appears to be considered an extension, and the remaining dots are changed to have an underscore prefix. However, this logic does not apply to the jQuery.js file, perhaps because the โextensionโ is one number? Here is a function that can translate the problems that I have had so far, but does not work along the jQuery.js path.
protected String _GetResourceName( String[] zSegments ) { String zResource = String.Empty; for ( int i = 0; i < zSegments.Length; i++ ) { if ( i != ( zSegments.Length - 1 )) { int iPos = zSegments[i].IndexOf( '.' ); if ( iPos != -1 ) { zSegments[i] = zSegments[i].Substring( 0, iPos + 1 ) + zSegments[i].Substring( iPos + 1 ).Replace( ".", "._" ); } } zResource += zSegments[i].Replace( '/', '.' ).Replace( '-', '_' ); } return String.Concat( _zAssemblyName, zResource ); }
Is there a function that can change names for me? What is it? Or where can I find all the rules so that I can write my own function? Thanks for any help you can provide.
Roel van uden
source share