[英]C# Error Access to the path 'C:\Windows\system32\Com\dmp' is denied When Windows Startup
thanks because you has been come to this post. 谢谢,因为你来过这个职位。 I have an error with my script, that log says:
我的脚本有错误,该日志显示:
Access to the path 'C:\\Windows\\system32\\Com\\dmp' is denied.
拒绝访问路径“ C:\\ Windows \\ system32 \\ Com \\ dmp”。
I want to set my application to windows startup , so when that computer client started, my software is automatically running. 我想将我的应用程序设置为Windows startup ,因此当该计算机客户端启动时,我的软件会自动运行。 So i put this script on my Main Load.
所以我把这个脚本放到我的主要负载上。
private void Main_Load(object sender, EventArgs e)
{
//Menjadikan software ke dalam Startup Windows, sehingga dapat berjalan ketika pc pertama kali dinyalakan
RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
reg.SetValue("PR Reminder", Application.ExecutablePath.ToString());
listMapel();
bool notif = Properties.Settings.Default.Notification;
if (notif == true)
{
checkExpired(); //Mengecek tanggal penyerahan dan pemberian
}
The result is work. 结果就是工作。 But I'm getting an error like this.
但是我遇到这样的错误。
After explored more deeply, the center of the issue is the method listMapel(); 经过更深入的探讨之后,问题的中心是listMapel();方法。 where he was tasked to search for files ending in .db in the local directory.
他的任务是在本地目录中搜索以.db结尾的文件。
I dont know why this method is got error. 我不知道为什么这种方法会出错。 When i try to remove this method, my application running fine when startup.
当我尝试删除此方法时,我的应用程序在启动时运行良好。 I think the problem is on system.io.
我认为问题出在system.io上。
This is my listMapel(); 这是我的listMapel(); method script
方法脚本
public void listMapel()
{
comboListMapel.Items.Clear();
string path = Directory.GetCurrentDirectory(); //Lokal direktori
string[] files = Directory.GetFiles(path, "*.db", SearchOption.AllDirectories);
foreach (string file in files)
{
nama = file.Split(".".ToCharArray()); //Hasil result yang ditampilkan Matapelajaran.db (Tapi dengan ini kita mengambil string sebelum .db
comboListMapel.Items.Add(Path.GetFileName(nama[0]));
}
}
授予对文件的访问权限,例如FileMode.Create,FileAccess.Write,FileShare。请不要尝试此操作,它可能会起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.