欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
C# 軟件開(kāi)機啟動(dòng)
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;
using Microsoft.Win32;using System.IO;
namespace WindowsFormsApp1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); // Class1.test(); // Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; }
private void button1_Click(object sender, EventArgs e) { MessageBox.Show("軟件自啟動(dòng)");
String LogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Log"); MessageBox.Show(Environment.CurrentDirectory+"\n"+LogPath);
//Class1.test(); }
private void Form1_Load(object sender, EventArgs e) { AutoStart(); }
private void AutoStart(bool isAuto = true, bool showinfo = true) { try { if (isAuto == true) { RegistryKey R_local = Registry.CurrentUser;//RegistryKey R_local = Registry.CurrentUser; RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); R_run.SetValue("應用名稱(chēng)", Application.ExecutablePath); R_run.Close(); R_local.Close(); } else { RegistryKey R_local = Registry.CurrentUser;//RegistryKey R_local = Registry.CurrentUser; RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); R_run.DeleteValue("應用名稱(chēng)", false); R_run.Close(); R_local.Close(); } }

// if (showinfo) // MessageBox.Show("您需要管理員權限修改", "提示"); // Console.WriteLine("您需要管理員權限修改"); catch (Exception ex) { String LogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Log"); if (!Directory.Exists(LogPath)) Directory.CreateDirectory(LogPath); if (!File.Exists(LogPath + "\\log.txt")) File.Create(LogPath + "\\log.txt").Close(); string fileName = LogPath + "\\log.txt"; string content = DateTime.Now.ToLocalTime() + " 0001_" + "您需要管理員權限修改" + "\n" + ex.StackTrace + "\r\n"; Logger(fileName, content);
}
} public static void disPlay(string path) {
MessageBox.Show(path); } public void Logger(string fileName, string content) {
using (StreamWriter sw = new StreamWriter(fileName, true)) { sw.Write(content); sw.Close(); sw.Dispose(); } } }}

運行后點(diǎn)擊按鈕:

,然后重啟后點(diǎn)擊按鈕:

發(fā)現沒(méi)?開(kāi)機自動(dòng)啟動(dòng)后

Environment.CurrentDirectory 發(fā)生了變更,

這樣在在我們程序中原本如果使用相對路徑進(jìn)行處理的,就找不見(jiàn)相應的文件了,

怎么處理?

方法1:

在程序初始化的時(shí)候改變下當前路徑

public Form1() {            InitializeComponent();           Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; }

方法2:添加環(huán)境變量 , 計算行--屬性--高級系統設置--環(huán)境變量--系統變量里面設置.

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
獲取文件路徑
獲取和設置c# 應用程序目錄
c#獲取當前應用程序所在路徑(轉) - CookBlack - 博客園
當類(lèi)庫項目中無(wú)法使用Application.StartupPath的時(shí)侯 (注:主要是在進(jìn)行反射讀取文件的時(shí)候??!)
C#插件開(kāi)發(fā)簡(jiǎn)單模型
C# 獲取當前路徑7種方法
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久