Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果进程由注册表/运行启动,C#File.exists将失败_C#_Mysql_Windows_Registry_Autostart - Fatal编程技术网

如果进程由注册表/运行启动,C#File.exists将失败

如果进程由注册表/运行启动,C#File.exists将失败,c#,mysql,windows,registry,autostart,C#,Mysql,Windows,Registry,Autostart,我正在制作一个使用Windows运行的监控应用程序(将注册表项添加到HKEY\U CURRENT\U USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run以使我的应用程序在Windows Start上运行) 下面是我的应用程序的行为: -它记录了一些信息 -它需要一个屏幕截图 -将所有内容上传到mysql -等待10秒钟 -一切都重新开始 在VisualStudio2015中编译应用程序时,一切正常。 当我决定在HKEY\u CURRENT\u U

我正在制作一个使用Windows运行的监控应用程序(将注册表项添加到
HKEY\U CURRENT\U USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
以使我的应用程序在Windows Start上运行)

下面是我的应用程序的行为:
-它记录了一些信息
-它需要一个屏幕截图
-将所有内容上传到mysql
-等待10秒钟
-一切都重新开始

在VisualStudio2015中编译应用程序时,一切正常。

当我决定在
HKEY\u CURRENT\u USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
中添加AutoStart键时,在Windows start上,应用程序“似乎”在“将所有内容上载到mysql”之前冻结,下面是“将所有内容上载到mysql”之前的代码:

如果应用程序是由注册表(Windows)启动的,是否有任何东西阻止我的应用程序使用“File.Exists” 我的应用程序是否具有相同的权限

我已经为此苦苦挣扎了两天,非常感谢您的帮助。

谢谢。

GetCurrentDirectory可能返回系统目录。看一看,了解一下你的想法。另外,对于路径创建,我建议使用类似这样的方法:
path.Combine(currentDir,“screenshots”,“screenscapture.jpeg”)
在windows启动时,并非所有内容都已启动,您可能希望使其成为在用户登录时运行的计划任务,而不是在windows启动时运行up@BugFinder我试着开始击球(等待20秒)不要直接在Windows上启动.exe,否则问题仍然存在。不要使用
目录。GetCurrentDirectory()
。如果文件应与可执行文件位于同一文件夹中,请使用
Path.GetDirectoryName(Assembly.getExecutionGassembly().Location)
获取目录名.Path.GetDirectoryName(Application.ExecutablePath);工作!你们是我的英雄。谢谢!
if (File.Exists(Directory.GetCurrentDirectory() + @"\screenshots\ScreenCapture.jpeg")) {