Application can't find settings or image files after windows bootHow can you find out which process is listening on a port on Windows?Windows batch files: .bat vs .cmd?How do I get the application exit code from a Windows command line?How to save application settings in a Windows Forms Application?Setting Windows PowerShell environment variablesRedirect Windows cmd stdout and stderr to a single fileHow to turn off Windows kernel debugging at boot time?System can't find operating system after creating vhd on blank diskSet a Linux USB drive as next boot device in Windows UEFI programmaticallyDual Boot Windows-Android on PC: How to switch OS programmatically?

Why do sellers care about down payments?

ArcMap not displaying attribute table?

Are there any space probes or landers which regained communication after being lost?

Job offer without any details but asking me to withdraw other applications - is it normal?

Action queue manager to perform action in a FIFO fashion

Can a new chain significantly improve the riding experience? If yes - what else can?

Were Roman public roads build by private companies?

Writing a love interest for my hero

Do any aircraft carry boats?

A medieval fantasy adventurer lights a torch in a 100% pure oxygen room. What happens?

Seized engine due to being run without oil

Is English tonal for some words, like "permit"?

Using the pipe operator ("|") when executing system commands

Are scroll bars dead in 2019?

What is the purpose of libraries like Pyomo and Google OR tools?

extract lines from bottom until regex match

Is it possible to PIVOT on a LIKE statement

Renewed US passport, did not receive expired US passport

My employer wants me to do a work of 6 months in just 2 months

Are the definite and indefinite integrals actually two different things? Where is the flaw in my understanding?

How to save PDFs from web for offline reading on an iPad?

Tracks in the snow

Is there a star over my head?

Contract Employer Keeps Asking for Small Things Without Pay



Application can't find settings or image files after windows boot


How can you find out which process is listening on a port on Windows?Windows batch files: .bat vs .cmd?How do I get the application exit code from a Windows command line?How to save application settings in a Windows Forms Application?Setting Windows PowerShell environment variablesRedirect Windows cmd stdout and stderr to a single fileHow to turn off Windows kernel debugging at boot time?System can't find operating system after creating vhd on blank diskSet a Linux USB drive as next boot device in Windows UEFI programmaticallyDual Boot Windows-Android on PC: How to switch OS programmatically?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have an application which boots after the windows boot. That works well, however the application can't seem to find the necessary csv file with settings or the necessary resources which result in a crash. However application works fine if I manually open it after I log in into my Windows account.



I tried to do a check if the csv file really exists, but as said above, the application can't find it. Since the csv file contains some settings and language data the application cannot run if the file isn't found



Before I read out the csv file, I check if the file exists by doing the following:



 try 
string langFile = Path.Combine(Settings.Default.WorkingDirectory, "languageSupport.csv"); //Get language file
// Read out the file
catch
MessageBox.Show("Could not load settings data!");
Console.WriteLine("Error occured: " + e.Message);



Also, I think it is important no note the following: This error only happens when the computer has been turned off for atleast a few hours. A reboot or shutting the pc down and turning it back on after a few minutes doesn't give me the error.



What can I do to improve this? Why does it crash when it boots automatically and not when I boot it manually?










share|improve this question


























  • Log down the full path whenever your application runs. So you can see where it's actually reading. If the path is right, your file may be lacking permission for whichever user account is running the application.

    – Vlam
    Mar 28 at 8:34












  • @Vlam I will try to do that. One question though, how can the file lack permission if the same user tries to open the application manually or after the user logs into his account?

    – Infiltrator
    Mar 28 at 8:48

















1















I have an application which boots after the windows boot. That works well, however the application can't seem to find the necessary csv file with settings or the necessary resources which result in a crash. However application works fine if I manually open it after I log in into my Windows account.



I tried to do a check if the csv file really exists, but as said above, the application can't find it. Since the csv file contains some settings and language data the application cannot run if the file isn't found



Before I read out the csv file, I check if the file exists by doing the following:



 try 
string langFile = Path.Combine(Settings.Default.WorkingDirectory, "languageSupport.csv"); //Get language file
// Read out the file
catch
MessageBox.Show("Could not load settings data!");
Console.WriteLine("Error occured: " + e.Message);



Also, I think it is important no note the following: This error only happens when the computer has been turned off for atleast a few hours. A reboot or shutting the pc down and turning it back on after a few minutes doesn't give me the error.



What can I do to improve this? Why does it crash when it boots automatically and not when I boot it manually?










share|improve this question


























  • Log down the full path whenever your application runs. So you can see where it's actually reading. If the path is right, your file may be lacking permission for whichever user account is running the application.

    – Vlam
    Mar 28 at 8:34












  • @Vlam I will try to do that. One question though, how can the file lack permission if the same user tries to open the application manually or after the user logs into his account?

    – Infiltrator
    Mar 28 at 8:48













1












1








1








I have an application which boots after the windows boot. That works well, however the application can't seem to find the necessary csv file with settings or the necessary resources which result in a crash. However application works fine if I manually open it after I log in into my Windows account.



I tried to do a check if the csv file really exists, but as said above, the application can't find it. Since the csv file contains some settings and language data the application cannot run if the file isn't found



Before I read out the csv file, I check if the file exists by doing the following:



 try 
string langFile = Path.Combine(Settings.Default.WorkingDirectory, "languageSupport.csv"); //Get language file
// Read out the file
catch
MessageBox.Show("Could not load settings data!");
Console.WriteLine("Error occured: " + e.Message);



Also, I think it is important no note the following: This error only happens when the computer has been turned off for atleast a few hours. A reboot or shutting the pc down and turning it back on after a few minutes doesn't give me the error.



What can I do to improve this? Why does it crash when it boots automatically and not when I boot it manually?










share|improve this question
















I have an application which boots after the windows boot. That works well, however the application can't seem to find the necessary csv file with settings or the necessary resources which result in a crash. However application works fine if I manually open it after I log in into my Windows account.



I tried to do a check if the csv file really exists, but as said above, the application can't find it. Since the csv file contains some settings and language data the application cannot run if the file isn't found



Before I read out the csv file, I check if the file exists by doing the following:



 try 
string langFile = Path.Combine(Settings.Default.WorkingDirectory, "languageSupport.csv"); //Get language file
// Read out the file
catch
MessageBox.Show("Could not load settings data!");
Console.WriteLine("Error occured: " + e.Message);



Also, I think it is important no note the following: This error only happens when the computer has been turned off for atleast a few hours. A reboot or shutting the pc down and turning it back on after a few minutes doesn't give me the error.



What can I do to improve this? Why does it crash when it boots automatically and not when I boot it manually?







c# windows settings boot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 9:01







Infiltrator

















asked Mar 28 at 8:30









InfiltratorInfiltrator

7410 bronze badges




7410 bronze badges















  • Log down the full path whenever your application runs. So you can see where it's actually reading. If the path is right, your file may be lacking permission for whichever user account is running the application.

    – Vlam
    Mar 28 at 8:34












  • @Vlam I will try to do that. One question though, how can the file lack permission if the same user tries to open the application manually or after the user logs into his account?

    – Infiltrator
    Mar 28 at 8:48

















  • Log down the full path whenever your application runs. So you can see where it's actually reading. If the path is right, your file may be lacking permission for whichever user account is running the application.

    – Vlam
    Mar 28 at 8:34












  • @Vlam I will try to do that. One question though, how can the file lack permission if the same user tries to open the application manually or after the user logs into his account?

    – Infiltrator
    Mar 28 at 8:48
















Log down the full path whenever your application runs. So you can see where it's actually reading. If the path is right, your file may be lacking permission for whichever user account is running the application.

– Vlam
Mar 28 at 8:34






Log down the full path whenever your application runs. So you can see where it's actually reading. If the path is right, your file may be lacking permission for whichever user account is running the application.

– Vlam
Mar 28 at 8:34














@Vlam I will try to do that. One question though, how can the file lack permission if the same user tries to open the application manually or after the user logs into his account?

– Infiltrator
Mar 28 at 8:48





@Vlam I will try to do that. One question though, how can the file lack permission if the same user tries to open the application manually or after the user logs into his account?

– Infiltrator
Mar 28 at 8:48












1 Answer
1






active

oldest

votes


















1
















It is because when it load automatically the working directory is different than when you open it manually from the .exe, try using AppDomain.CurrentDomain.BaseDirectory to make sure that paths are relative to your application, also you can use it to specify the .csv file path, assuming that the file is in the same directory as your application:



try 
string langFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "languageSupport.csv"); //Get language file
// Read out the file
catch
MessageBox.Show("Could not load settings data!");
Console.WriteLine("Error occured: " + e.Message);






share|improve this answer



























  • I don't think that this solution is a good one. Yes, it might work but what if the user installs the application in a different folder? That's why I set the WorkingDirectory in the Settings file so the user can install the application anywhere on their device

    – Infiltrator
    Mar 28 at 8:46







  • 1





    @Infiltrator try the updated answer hope it helps you

    – Ali Ezzat Odeh
    Mar 28 at 8:54











  • Thanks, will try that out. Maybe it's also important to note the following: This error only happens when the computer has been turned off for atleast a few hours. A reboot or shutting the pc down and rebooting it after some minutes doesn't give me the error.

    – Infiltrator
    Mar 28 at 9:00











  • Good then try it to check that this gives you a consistent behavior

    – Ali Ezzat Odeh
    Mar 28 at 9:04











  • Seems to work after the first night. Will test this furter, but thanks for this solution!

    – Infiltrator
    Mar 29 at 7:50










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393080%2fapplication-cant-find-settings-or-image-files-after-windows-boot%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1
















It is because when it load automatically the working directory is different than when you open it manually from the .exe, try using AppDomain.CurrentDomain.BaseDirectory to make sure that paths are relative to your application, also you can use it to specify the .csv file path, assuming that the file is in the same directory as your application:



try 
string langFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "languageSupport.csv"); //Get language file
// Read out the file
catch
MessageBox.Show("Could not load settings data!");
Console.WriteLine("Error occured: " + e.Message);






share|improve this answer



























  • I don't think that this solution is a good one. Yes, it might work but what if the user installs the application in a different folder? That's why I set the WorkingDirectory in the Settings file so the user can install the application anywhere on their device

    – Infiltrator
    Mar 28 at 8:46







  • 1





    @Infiltrator try the updated answer hope it helps you

    – Ali Ezzat Odeh
    Mar 28 at 8:54











  • Thanks, will try that out. Maybe it's also important to note the following: This error only happens when the computer has been turned off for atleast a few hours. A reboot or shutting the pc down and rebooting it after some minutes doesn't give me the error.

    – Infiltrator
    Mar 28 at 9:00











  • Good then try it to check that this gives you a consistent behavior

    – Ali Ezzat Odeh
    Mar 28 at 9:04











  • Seems to work after the first night. Will test this furter, but thanks for this solution!

    – Infiltrator
    Mar 29 at 7:50















1
















It is because when it load automatically the working directory is different than when you open it manually from the .exe, try using AppDomain.CurrentDomain.BaseDirectory to make sure that paths are relative to your application, also you can use it to specify the .csv file path, assuming that the file is in the same directory as your application:



try 
string langFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "languageSupport.csv"); //Get language file
// Read out the file
catch
MessageBox.Show("Could not load settings data!");
Console.WriteLine("Error occured: " + e.Message);






share|improve this answer



























  • I don't think that this solution is a good one. Yes, it might work but what if the user installs the application in a different folder? That's why I set the WorkingDirectory in the Settings file so the user can install the application anywhere on their device

    – Infiltrator
    Mar 28 at 8:46







  • 1





    @Infiltrator try the updated answer hope it helps you

    – Ali Ezzat Odeh
    Mar 28 at 8:54











  • Thanks, will try that out. Maybe it's also important to note the following: This error only happens when the computer has been turned off for atleast a few hours. A reboot or shutting the pc down and rebooting it after some minutes doesn't give me the error.

    – Infiltrator
    Mar 28 at 9:00











  • Good then try it to check that this gives you a consistent behavior

    – Ali Ezzat Odeh
    Mar 28 at 9:04











  • Seems to work after the first night. Will test this furter, but thanks for this solution!

    – Infiltrator
    Mar 29 at 7:50













1














1










1









It is because when it load automatically the working directory is different than when you open it manually from the .exe, try using AppDomain.CurrentDomain.BaseDirectory to make sure that paths are relative to your application, also you can use it to specify the .csv file path, assuming that the file is in the same directory as your application:



try 
string langFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "languageSupport.csv"); //Get language file
// Read out the file
catch
MessageBox.Show("Could not load settings data!");
Console.WriteLine("Error occured: " + e.Message);






share|improve this answer















It is because when it load automatically the working directory is different than when you open it manually from the .exe, try using AppDomain.CurrentDomain.BaseDirectory to make sure that paths are relative to your application, also you can use it to specify the .csv file path, assuming that the file is in the same directory as your application:



try 
string langFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "languageSupport.csv"); //Get language file
// Read out the file
catch
MessageBox.Show("Could not load settings data!");
Console.WriteLine("Error occured: " + e.Message);







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 28 at 8:54

























answered Mar 28 at 8:35









Ali Ezzat OdehAli Ezzat Odeh

1,7541 gold badge11 silver badges17 bronze badges




1,7541 gold badge11 silver badges17 bronze badges















  • I don't think that this solution is a good one. Yes, it might work but what if the user installs the application in a different folder? That's why I set the WorkingDirectory in the Settings file so the user can install the application anywhere on their device

    – Infiltrator
    Mar 28 at 8:46







  • 1





    @Infiltrator try the updated answer hope it helps you

    – Ali Ezzat Odeh
    Mar 28 at 8:54











  • Thanks, will try that out. Maybe it's also important to note the following: This error only happens when the computer has been turned off for atleast a few hours. A reboot or shutting the pc down and rebooting it after some minutes doesn't give me the error.

    – Infiltrator
    Mar 28 at 9:00











  • Good then try it to check that this gives you a consistent behavior

    – Ali Ezzat Odeh
    Mar 28 at 9:04











  • Seems to work after the first night. Will test this furter, but thanks for this solution!

    – Infiltrator
    Mar 29 at 7:50

















  • I don't think that this solution is a good one. Yes, it might work but what if the user installs the application in a different folder? That's why I set the WorkingDirectory in the Settings file so the user can install the application anywhere on their device

    – Infiltrator
    Mar 28 at 8:46







  • 1





    @Infiltrator try the updated answer hope it helps you

    – Ali Ezzat Odeh
    Mar 28 at 8:54











  • Thanks, will try that out. Maybe it's also important to note the following: This error only happens when the computer has been turned off for atleast a few hours. A reboot or shutting the pc down and rebooting it after some minutes doesn't give me the error.

    – Infiltrator
    Mar 28 at 9:00











  • Good then try it to check that this gives you a consistent behavior

    – Ali Ezzat Odeh
    Mar 28 at 9:04











  • Seems to work after the first night. Will test this furter, but thanks for this solution!

    – Infiltrator
    Mar 29 at 7:50
















I don't think that this solution is a good one. Yes, it might work but what if the user installs the application in a different folder? That's why I set the WorkingDirectory in the Settings file so the user can install the application anywhere on their device

– Infiltrator
Mar 28 at 8:46






I don't think that this solution is a good one. Yes, it might work but what if the user installs the application in a different folder? That's why I set the WorkingDirectory in the Settings file so the user can install the application anywhere on their device

– Infiltrator
Mar 28 at 8:46





1




1





@Infiltrator try the updated answer hope it helps you

– Ali Ezzat Odeh
Mar 28 at 8:54





@Infiltrator try the updated answer hope it helps you

– Ali Ezzat Odeh
Mar 28 at 8:54













Thanks, will try that out. Maybe it's also important to note the following: This error only happens when the computer has been turned off for atleast a few hours. A reboot or shutting the pc down and rebooting it after some minutes doesn't give me the error.

– Infiltrator
Mar 28 at 9:00





Thanks, will try that out. Maybe it's also important to note the following: This error only happens when the computer has been turned off for atleast a few hours. A reboot or shutting the pc down and rebooting it after some minutes doesn't give me the error.

– Infiltrator
Mar 28 at 9:00













Good then try it to check that this gives you a consistent behavior

– Ali Ezzat Odeh
Mar 28 at 9:04





Good then try it to check that this gives you a consistent behavior

– Ali Ezzat Odeh
Mar 28 at 9:04













Seems to work after the first night. Will test this furter, but thanks for this solution!

– Infiltrator
Mar 29 at 7:50





Seems to work after the first night. Will test this furter, but thanks for this solution!

– Infiltrator
Mar 29 at 7:50








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393080%2fapplication-cant-find-settings-or-image-files-after-windows-boot%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현