September 16, 2021, 18:59:21

Author Topic: windows 10 - creating folder from blitzmax ng causes errors  (Read 486 times)

Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
ok here is my scenario

Code: [Select]
' createfile.bmx
SuperStrict

Local success:Int = CreateFile("C:\Program Files\Specdrum\Kits\bits.txt")
If Not success Then
RuntimeError "error creating file"
End If

this is an example that is from the blitzmax ng help on the createfile command

when i run this in a standard user of windows 10 it cant create the file and reports back error creating it as what it says in the code ,,,

but when i run this as an administrator it works fine

what do i need to do to stop windows 10 mucking up my life lol

any help is appreciated

Lee

Offline col

  • Hero Member
  • *****
  • Posts: 590
Re: windows 10 - creating folder from blitzmax ng causes errors
« Reply #1 on: April 04, 2021, 16:05:44 »
You need to do as Windows wants - store your files in an area where you are allowed to as a regular user - That would be any folder within your username - ie c:\users\*USERNAME*\anywhere here.

Program files area is definitely off limits to regular users to create files and folders there.

I believe NG has a 'volumes' modules to help out exactly this issue you are having.
Maybe Derron will chime in here as it's my understanding that he is well versed with this module.

Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: windows 10 - creating folder from blitzmax ng causes errors
« Reply #2 on: April 04, 2021, 16:23:46 »
arrrr yes i see

so basically install it to the public area (my program i mean ) so that program can access without a hitch

:)

Lee

Offline Henri

  • Sr. Member
  • ****
  • Posts: 353
Re: windows 10 - creating folder from blitzmax ng causes errors
« Reply #3 on: April 04, 2021, 16:24:38 »
Hi,

you can use appData-folder for user level read/write access, or programData-folder for application level access (type %appData% or %programData% into your explorer address bar).

Use Windows API to get folder locations rather then hard coding them. Blitzmax ng has volumes.mod included (look for brl/volumes.mod).

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Offline col

  • Hero Member
  • *****
  • Posts: 590
Re: windows 10 - creating folder from blitzmax ng causes errors
« Reply #4 on: April 04, 2021, 17:04:41 »
Quote
so basically install it to the public area (my program i mean )
Normally you would use an installer to install your application (as admin) to the Program Files area, and your application will save data to where it is allowed to as a regular user. I use InnoSetup myself for installation and found it to do everything I could possibly need to do during installing/updating.

As Henri points out  - AppData folder or Program Data folder are the 'usual' places for Win10. AppData is within each user folder. ProgramData is in the C:\ folder but always use the correct API (either via the Win32 APIs or via the volumes.mod API) and let that interrogate the system to find where the correct folder is - it will be different for different version of an OS and certainly different across different platforms :)

Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: windows 10 - creating folder from blitzmax ng causes errors
« Reply #5 on: April 04, 2021, 19:17:51 »
Cheers guys

Will look into it

Offline Derron

  • Hero Member
  • *****
  • Posts: 3651
Re: windows 10 - creating folder from blitzmax ng causes errors
« Reply #6 on: April 05, 2021, 11:56:59 »
If your app is planned to be "portable" (so unzip/unarchive and run...) it might be even a worthy idea to check the current working directory versus the "programme folder".
But as there are multiple file locations possible - it might be a good idea to check if you are "able" to write inside the folders.


The "doc" folder of volumes.mod contains the required examples to find the "app data" folder


@Henri and col
I am not sure - but might such a check trigger the system "acl" dialogue ? (that something needs access to write to ..) Might then be something the dev does not want to do.


bye
Ron

Offline Pingus

  • Full Member
  • ***
  • Posts: 134
Re: windows 10 - creating folder from blitzmax ng causes errors
« Reply #7 on: April 05, 2021, 14:47:27 »
Code: [Select]
files_path$=GetUserAppDir()+ "\" if that can be of any use.

Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: windows 10 - creating folder from blitzmax ng causes errors
« Reply #8 on: June 07, 2021, 23:17:05 »
yeah cheers for that , i did sort it , just got the files to install to the public folder in windows 10 , admin rights was locking the access to the folders out :)

sorted now

lee

Offline col

  • Hero Member
  • *****
  • Posts: 590
Re: windows 10 - creating folder from blitzmax ng causes errors
« Reply #9 on: June 08, 2021, 07:22:35 »
Quote
I am not sure - but might such a check trigger the system "acl" dialogue ?
Triggering the ACL is normally associated with running an exe, accessing another users folders, or another domain etc. -somewhere that the user doesn't have 'general read' access.
With creating files and folders within the users 'read' access, the action would normally fail with an 'access denied' error code if the user doesn't have the rights to do exactly what they want to do.

Something like that anyway  :))
« Last Edit: June 08, 2021, 11:30:18 by col »

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal