第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

C# 在應(yīng)用程序配置文件中設(shè)置 appdata 或任何特殊文件夾路徑

C# 在應(yīng)用程序配置文件中設(shè)置 appdata 或任何特殊文件夾路徑

C#
慕妹3242003 2022-07-10 16:36:41
我試圖找到一種方法將 appdata 路徑用作我的 environment.currentduretory,這意味著我想從 appdata 文件夾運(yùn)行 c# 應(yīng)用程序,并且在我的項(xiàng)目中我總是使用 environment.currentdirectory。我找不到一種方法可以在應(yīng)用程序配置中設(shè)置 appdata 路徑,然后用 appdata 路徑替換 environment.curentdirectory ...PS:。1)我想將我的程序數(shù)據(jù)路徑設(shè)置為 appdata2)我的項(xiàng)目代碼設(shè)置為使用 environment.currentdirectory3)我不想通過逐行替換 environment.currentdirectory目標(biāo) .Net 框架 4
查看完整描述

2 回答

?
炎炎設(shè)計(jì)

TA貢獻(xiàn)1808條經(jīng)驗(yàn) 獲得超4個(gè)贊

您是否嘗試過通過應(yīng)用程序域執(zhí)行此操作。


看:


https://docs.microsoft.com/en-us/dotnet/api/system.appdomain.basedirectory?view=netframework-4.7.2


    // Create application domain setup information

    var domaininfo = new AppDomainSetup();

    domaininfo.ConfigurationFile = System.Environment.CurrentDirectory + 

                                   Path.DirectorySeparatorChar +

                                   "ADSetup.exe.config";

    domaininfo.ApplicationBase = System.Environment.CurrentDirectory;


    //Create evidence for the new appdomain from evidence of the current application domain

    Evidence adEvidence = AppDomain.CurrentDomain.Evidence;


    // Create appdomain

    AppDomain domain = AppDomain.CreateDomain("Domain2", adEvidence, domaininfo);


    // Display application domain information.

    Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName);

    Console.WriteLine("Child domain: " + domain.FriendlyName);

    Console.WriteLine();

    Console.WriteLine("Configuration file: " + domain.SetupInformation.ConfigurationFile);

    Console.WriteLine("Application Base Directory: " + domain.BaseDirectory);


    AppDomain.Unload(domain);


查看完整回答
反對(duì) 回復(fù) 2022-07-10
?
素胚勾勒不出你

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超9個(gè)贊

所以,我發(fā)現(xiàn)除非我們?cè)O(shè)置任何,否則我們無法直接從配置文件中獲取應(yīng)用程序數(shù)據(jù)路徑。

最好的使用 se 只是獲取應(yīng)用程序數(shù)據(jù)路徑

Environment.specialfolder 方法并使用它。

否則上面發(fā)布的答案是由 MSDN 本身給出的,顯然有效,但代碼太大


查看完整回答
反對(duì) 回復(fù) 2022-07-10
  • 2 回答
  • 0 關(guān)注
  • 249 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)