2013-02-26 67 views
0

我有一個資源項目,用於我們產品的各個部分。爲了使它更加靈活,我決定將外部的.resx文件放在用resgen工具處理的dll中,以允許用戶即時添加他們自己的語言文件。由於該項目將從不同的地方,網絡,服務或獨立的WinForm的,我怎麼能得到的,其中該.dll位於這樣我可以爲如何在運行時獲取組裝路徑,在web服務器,服務或win應用程序中運行

[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 
    public static global::System.Resources.ResourceManager ResourceManager { 
     get { 
      if (object.ReferenceEquals(resourceMan, null)) { 
       temp = ResourceManager.CreateFileBasedResourceManager("Resources", cwd, null); 
       resourceMan = temp; 
      } 
      return resourceMan; 
     } 
    } 

我能提供正確的路徑的路徑來訪問硬編碼的路徑,它的工作很好,但我寧願讓它在運行時找出路徑。

我想這樣的事情,但它沒有工作

string fullPath = System.Reflection.Assembly.GetAssembly(typeof(Resources)).Location; 

//get the folder that's in 
string theDirectory = Path.GetDirectoryName(fullPath); ResourceManager temp = 

"Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. 

baseName的:資源locationInfo:文件名:Resources.resources」

回答

相關問題