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

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?