0
votes

I have small vb.net application which stores settings in SQL Server compact database file abc.sdf. While installation I am storing this file in Local Appdata folder which translates to

"C:\Users\\AppData\Local\\abc.sdf"

In Windows Server 2012 when I am running my application from a non-admin user the application is throwing the error "database file not found". I didn't get this error while running the application with "Run as Admin" option.

This problem is specific to Windows Server only, the application is running without any issues in Windows 7,8 and 10.

I have tried changing the ownership of the file, granting full control permission to everyone, users etc. but, none is working.

I am not able to view the file in localappdata folder if logged in as a non-admin user. But when I logged in as Admin user it's showing the file.

I don't know much about Windows Server 2012 any help will be highly appreciated.

1

1 Answers

0
votes

Do you need to have the file in appdata, or can you have it in the file where the programme is in. If so, you can access it like this:

Dim Filename As String = $"{AppDomain.CurrentDomain.BaseDirectory}abc.sdf"

If it is required to be in the local appdata folder, you can try:

Dim Filename as String = $"{GetFolderPath(SpecialFolder.ApplicationData)}Local\abc.sdf"

You also need to insert: Imports System.Environment at the top of your code