14 Replies - 855 Views - Last Post: 08 December 2019 - 09:28 AM Rate Topic: -----

#1 Danamo51   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 03-November 19

Problems with User's Application Data Folder after Setup

Posted 29 November 2019 - 03:22 PM

In my VB.NET (Visual Studio 2017) project I have several folders with data which need to be installed by the .msi setup, and my application needs to read/write in those folders as well.

However, when my application is run after being installed by the msi I get all kinds of errors related to not finding the app's folder paths or write-access to those folders being denied.

In my Setup project, for the File System on Target Machine, I have added the User's Application Data Folder, and added the folders I need there, and added the data files used by my application into those folders. The "Always Create" property is True for these folders.

In code I am specifying "Application.LocalUserAppDataPath" as the path for my working folders and relative to the files I need to read/write,.

The .msi installer, however, is not creating my folders in the LocalUserAppDataPath. It does create the app data path, at
C:\Users\UserName\AppData\Roaming\MyApp\MyApp\1.0.0.0 (for example) but it doesn't create the folders I specified in the setup into that folder. The rest of the installation seems okay, it creates the shortcuts in the Program Menu and Desktop, and the program does launch from there, so at least I got that part of the setup right!

When I run the program from Visual Studio in the Debug or Release modes it works without any problems. (I put copies of my folders and files in both the Debug and Release folders.) So my code in the app's forms seems okay and the problem then is in how I'm defining the setup project for my app.

What the heck am I doing wrong? Is LocalUserAppDataPath the wrong place to be putting my folders and files in the setup, or is Application.LocalUserAppDataPath the wrong place I should be trying to access my app's folders and files in code? Also, is Application.LocalUserAppDataPath a read-only location like the Program Files(x86) folder?

The files in my setup's User's Application Data Folder and its sub-folders all have blue squiggly lines under them, like "^ ^ ^" which I guess is indicating some kind of problem there? but I have no clue what, if so.

If I didn't need to deploy this app to more than one computer I would skip this whole clusterF*** mess of complicated byzantine setup methods used by Visual Studio and just manually create a folder for the app on the C: drive and use the direct path to that folder in my code!

Is This A Good Question/Topic? 0
  • +

Replies To: Problems with User's Application Data Folder after Setup

#2 LadyCynthia   User is offline

  • D.I.C Head

Reputation: 26
  • View blog
  • Posts: 106
  • Joined: 29-December 16

Re: Problems with User's Application Data Folder after Setup

Posted 30 November 2019 - 07:49 AM

Silly question but have you tried right clicking the msi and choosing Run as administrator. The heightened permissions might solve the problem.
Was This Post Helpful? 0
  • +
  • -

#3 Danamo51   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 03-November 19

Re: Problems with User's Application Data Folder after Setup

Posted 30 November 2019 - 09:07 AM

View PostLadyCynthia, on 30 November 2019 - 02:49 PM, said:

Silly question but have you tried right clicking the msi and choosing Run as administrator. The heightened permissions might solve the problem.


Thanks for your response. No, I hadn't tried running the msi as administrator, so I followed your suggestion and attempted to do that. But right-clicking the msi did not give me an option to run as administrator. The only option in the menu was Install. However, right-clicking the Setup exe which is also created when building the installer project did give me the option to run as administrator. The results were still the same, though. My sub-folders and files aren't being created in the User's Application Data Folder by the installer.

Do you know what is indicated by the squiggly blue lines under the filenames I added into my sub-folders in the User's Application Data Folder part of my setup project? I suspect it's telling me there's a problem there, but I don't know what it means.
Was This Post Helpful? 0
  • +
  • -

#4 LadyCynthia   User is offline

  • D.I.C Head

Reputation: 26
  • View blog
  • Posts: 106
  • Joined: 29-December 16

Re: Problems with User's Application Data Folder after Setup

Posted 30 November 2019 - 08:04 PM

Next step will be to generate a log file to see what the issue is. Do that by opening a command prompt and issuing the command below making sure to replace the paths with your values.

msiexec /i "C:\MyPackage\Example.msi" /L*V "C:\log\example.log"
Was This Post Helpful? 1
  • +
  • -

#5 Danamo51   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 03-November 19

Re: Problems with User's Application Data Folder after Setup

Posted 02 December 2019 - 11:41 AM

View PostLadyCynthia, on 01 December 2019 - 03:04 AM, said:

Next step will be to generate a log file to see what the issue is. Do that by opening a command prompt and issuing the command below making sure to replace the paths with your values.

msiexec /i "C:\MyPackage\Example.msi" /L*V "C:\log\example.log"

Okay, I did as you suggested, generated the log file, and have looked through it. It seems that the installer is creating and populating my User Data folders in the root of ...\\AppData\Roaming rather than in ...\AppData\Roaming\MyApplication\Etc\..

This explains why my app, when run, is unable to locate its data folders and content, since when I specify "Application.UserAppDataPath" in my code it returns the full path to \MyApplication\, not to the root of \Roaming.

Isn't "User's Application Data Folder" the correct place to be putting my content in the "File System on Target Machine" in the Primary Output of my setup? And are all of these "special folders" restricted to read-only?

I guess my question/problem boils down to... what is the correct way to specify in my setup project where my application's read-write data folders should be created (and populated), and then in my code, how do I get the path to those folders if it's not "Application.UserAppDataPath"?

Sorry I'm so dense about this!
Was This Post Helpful? 0
  • +
  • -

#6 LadyCynthia   User is offline

  • D.I.C Head

Reputation: 26
  • View blog
  • Posts: 106
  • Joined: 29-December 16

Re: Problems with User's Application Data Folder after Setup

Posted 02 December 2019 - 01:17 PM

The user's app data folder is definitely the right place to be storing your files. You should be able to just append your application folder name onto the base Roaming path. Can you share a few lines where you copy the files?
Was This Post Helpful? 0
  • +
  • -

#7 Danamo51   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 03-November 19

Re: Problems with User's Application Data Folder after Setup

Posted 03 December 2019 - 10:29 AM

View PostLadyCynthia, on 02 December 2019 - 08:17 PM, said:

The user's app data folder is definitely the right place to be storing your files. You should be able to just append your application folder name onto the base Roaming path. Can you share a few lines where you copy the files?

Thanks again for continuing to help me with this.

I'm not copying the files with line of code, per se. In the Primary Output of my setup, in the sub-folders which I added into the User's Application Data Folder, I right-click and "Add Files" to populate those folders with their content.

If it will help, here is a link to a screenshot of my setup's Primary Output...
http://www.danamo.co...rgetMachine.jpg
and a screenshot of one of my content folders in the setup...
http://www.danamo.com/StockPhotos.jpg (note the squiggly blue lines under the filenames?)

I'm providing the pics as web links since for some reason I get an error when trying to upload them to the D.I.C. website as attachments to my message here. One problem after another, *sigh*

Anyway, the setup does create and populate my content folders, but it puts them in the root path of \Roaming rather than in \Roaming\MyApplication.

And the setup does create my application root folder, but it doesn't put anything in it. To explain it better, my application is named "Garden Planner" and one of my folders with content is named "Stock Photos". The setup is putting Stock Photos in the C:\Users\UserName\AppData\Roaming folder. It is also creating a folder C:\Users\MyUserName\AppData\Roaming\Garden Planner\Garden Planner\1.0.0.0 which is the path returned by Application.UserAppDataPath in my code. But that folder is empty.

Obviously I'm doing something wrong... I've looked at numerous website instructions and examples to get this far in creating my installer, but I'm at my wit's end, and with my limited intelligence that's not much of a distance, LOL. So your help is greatly appreciated!
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15477
  • View blog
  • Posts: 62,007
  • Joined: 12-June 08

Re: Problems with User's Application Data Folder after Setup

Posted 03 December 2019 - 10:36 AM

How are you creating folders?

Relative to 'My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData'?

https://docs.microso...etframework-4.8
Was This Post Helpful? 0
  • +
  • -

#9 Danamo51   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 03-November 19

Re: Problems with User's Application Data Folder after Setup

Posted 03 December 2019 - 11:13 AM

View Postmodi123_1, on 03 December 2019 - 05:36 PM, said:

How are you creating folders?

Relative to 'My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData'?

https://docs.microso...etframework-4.8

Thanks for your question.

I am creating my application's content folders by right-clicking on "File System on Target Machine" in my setup's Primary Output screen, and then adding Special Folder, User's Application Data Folder. And then in the User's Application Data Folder I right-click and Add/Folder to define my content folders. And then in those folders I right-click to Add/File and add my content files there, which I select by navigating to the source folders on my computer which contain the original content files.

Please refer to the screenshot links I provided in my previous post which perhaps show this better than I am explaining in words.

In my code, to access those folders and files I am referencing Application.UserAppDataPath, as in Application.UserAppDataPath & "\FolderName\" & FileName
Was This Post Helpful? 0
  • +
  • -

#10 LadyCynthia   User is offline

  • D.I.C Head

Reputation: 26
  • View blog
  • Posts: 106
  • Joined: 29-December 16

Re: Problems with User's Application Data Folder after Setup

Posted 03 December 2019 - 04:02 PM

You need to make an Application Name folder and place your other folders inside of it and target them. You may need to use an external tool to achieve this. Orca is the one that comes to mind.


https://docs.microso...32/msi/orca-exe
Was This Post Helpful? 1
  • +
  • -

#11 Danamo51   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 03-November 19

Re: Problems with User's Application Data Folder after Setup

Posted 04 December 2019 - 12:00 PM

View PostLadyCynthia, on 03 December 2019 - 11:02 PM, said:

You need to make an Application Name folder and place your other folders inside of it and target them. You may need to use an external tool to achieve this. Orca is the one that comes to mind.


https://docs.microso...32/msi/orca-exe

Thank you for continuing to take the time to look at my problem and offer advice.

It seems bizarre to me that Microsoft would provide the option in their installer to create user APPLICATION data folders but not allow you to put those folders in the APPLICATION's folder... and additionally, not to provide a code path to those data folders.

What's the point of a User Application Data Folder that can't be accessed or used by the Application.UserAppDataPath in the application's code?

And then to add the complications of an external tool? Is it really that uncommon for an application to read and write its own files in its own folders, so that one has to jump through all these hoops to do it? Reading and writing files is one of the most basic functions of virtually every program I've ever seen or used in any language on any OS platform, so it should be one of the easiest, not most difficult, to implement. *sigh*

Sorry for my rant. It's directed at Microsoft, not at you, LadyCynthia. You've been very patient, helpful, and kind with me.

In any case, since on any user's personal machine, the path to \Roaming is always going to be C:\Users\UserName\AppData\Roaming, at this point it's easier for me to just keep the installer as-is, let it go ahead and put my folders in \Roaming, and then in my program code, since I know where those folders are going to be, simply build a path string in code by parsing the Application.UserAppDataPath to get the path to the Roaming folder and then append my folders' names onto that for my file read/writes.

(or maybe there is some built-in coded variable in vb.net that will give the path to the Roaming folder directly, like system.environment....roaming folder?)

Anyway, most users aren't going to be mucking about in the Roaming folder or objecting to the presence of a couple of my application's sub-folders being located there instead of tucked away neatly in the Application.UserAppDataPath, so I don't see how doing it this way should be a problem for anyone except the Code Overlords who object to doing anything outside of their impenetrable box.
Was This Post Helpful? 0
  • +
  • -

#12 Dreamfall   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 171
  • Joined: 26-January 15

Re: Problems with User's Application Data Folder after Setup

Posted 05 December 2019 - 11:29 AM

@Danamo51 are you trying to create an installer ?? the road taken is completely wrong, there are other ways and other languages ​​maybe easier, maybe more difficult, without excluding the possibility of doing so also from VB.
Was This Post Helpful? 0
  • +
  • -

#13 Danamo51   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 03-November 19

Re: Problems with User's Application Data Folder after Setup

Posted 06 December 2019 - 04:00 PM

View PostDreamfall, on 05 December 2019 - 06:29 PM, said:

@Danamo51 are you trying to create an installer ?? the road taken is completely wrong, there are other ways and other languages ​​maybe easier, maybe more difficult, without excluding the possibility of doing so also from VB.

Indeed, yes, I am trying to create an installer for my application.

How is the road taken completely wrong? I am sure there are other ways and other languages, but I am trying to do it in VB using the procedures and methods established in Visual Studio specifically for creating installers, and as instructed by numerous online tutorials and examples, including ones from Microsoft themselves.

Having determined that the installer is not placing my data folders in the expected locations, but knowing where it is locating them, and referencing those paths in my code, the installer - and my application - is now working perfectly.

I would agree that the road to a Visual Studio application installer is rocky path leading through quagmires which should be braved only by the intrepid, but unless there is some remarkably much simpler way of creating an installer for my VB application that doesn't require learning/using another language, I am not prepared to monkey with what I finally have gotten to work.
Was This Post Helpful? 0
  • +
  • -

#14 Dreamfall   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 171
  • Joined: 26-January 15

Re: Problems with User's Application Data Folder after Setup

Posted 07 December 2019 - 03:14 AM

If you think you are satisfied with your work, then that's okay. Instead you could use "ISS" Inno Setup Compiler, but you should learn to use another language.
Continuing with VB, the steps to create a custom installer are those to use a "FreeArc" file archiver in addition to different exsternal compressors, in order to compress the data used to be installed, and to make the installation weigh as little as possible for your client. Finally from code with VB you can create the impossible or almost. :D/>/> until you get to something like that.

Example

but I don't know if you want to go so far.
Was This Post Helpful? 0
  • +
  • -

#15 Danamo51   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 03-November 19

Re: Problems with User's Application Data Folder after Setup

Posted 08 December 2019 - 09:28 AM

View PostDreamfall, on 07 December 2019 - 10:14 AM, said:

If you think you are satisfied with your work, then that's okay. Instead you could use "ISS" Inno Setup Compiler, but you should learn to use another language.
Continuing with VB, the steps to create a custom installer are those to use a "FreeArc" file archiver in addition to different exsternal compressors, in order to compress the data used to be installed, and to make the installation weigh as little as possible for your client. Finally from code with VB you can create the impossible or almost. :D/>/>/> until you get to something like that.

Example

but I don't know if you want to go so far.

Thanks for your input.

With today's technology, where a 128 gigabyte SSD boot drive is considered "small" what would be an acceptable weight for an installer package?

The installer created by Visual Studio for my VB application, which includes 4 folders containing user files and data in addition to the application .exe itself, has a total weight of 3.9 megabytes. About the size of one large jpeg picture or one mp3 music file.

I suppose I could employ some other type of installer which utilizes compression to reduce the installer's weight, but I think this would be the digital equivalent of anorexia in my particular case.

As for learning other languages, my attitude is that one doesn't need to learn how to speak Italian just to order a pizza for delivery.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1