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;
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
add a comment |
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
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
add a comment |
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
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
c# windows settings boot
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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);
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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);
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
add a comment |
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);
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
add a comment |
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);
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);
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
add a comment |
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
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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