-1

In Debug Mode, I can successfully obtain the directory of the executable path, and here is a reference link on how that is achieved:

Obtaining Application Folder Path

The problem is that none of these methods are effective in Release Mode. It doesn't error out, but the line of code gets skipped over completely. An example of a code snippet that won't execute is:

Dim strDir as String = Environment.CurrentDirectory

In debug mode, the above executes properly (strDir will contain the appropriate directory). In release mode, the above will skip execution completely, leaving strDir as Nothing or empty. Any ideas on what I can do?

Thanks!

Community
  • 1
  • 1
Mike
  • 235
  • 3
  • 15
  • 1
    When deployed you may not have permission to read/write files or create directories to a location relative to where the app is installed. That code bears no resemblance to that in the link and `Function()` is just....whimsical. Windows provides for several folders for app data – Ňɏssa Pøngjǣrdenlarp Dec 16 '16 at 01:25
  • By the by, you can set it up so the Debug app runs from a folder other than whereever your VS folders are. Use the Debug tab under Project -> Properties – Ňɏssa Pøngjǣrdenlarp Dec 16 '16 at 01:45
  • 1
    There is no code in the post that resembles anything related to using "application folder path"... Please review [MCVE] guidance and [edit] post to align code sample, body text and the title. – Alexei Levenkov Dec 16 '16 at 02:00
  • My reference to Application Folder Path just tries to emphasize that I understand all the ways to get the app folder path, but none of the examples just don't want to work in Release mode, which is the main issue I am still having. I'm just trying to figure out how to get anything "Directory" related to work in the Release mode. – Mike Dec 16 '16 at 02:07
  • I removed my original example and replaced it with a more relevant one, to help with clarity. – Mike Dec 16 '16 at 02:14
  • Please share the code that "doesn't work in Release mode." – Edmund Schweppe Dec 16 '16 at 04:06

1 Answers1

0

Release mode debugging is different than debugging in debug mode. It is not as straight forward to step through code line by line due to the code being optimized; some flow paths may be different.

I will say this...It is very important to frequently compile your code in both debug and release mode, which is something I have not been doing. There really was no issue other than the fact that I somehow hit another irrelevant bug in release mode, and I tried to step through the code. I noticed that when I tried to step over this line:

Dim strDir as String = Environment.CurrentDirectory

It jumped past the line and I couldn't observe the value. I mistakenly thought this was an issue. But what I learned in release mode is that this is normal. I apologize for posting this question, can someone please close it?

Thank you all.

Mike
  • 235
  • 3
  • 15