2

While developing Labview code for a Windows 7 operating system, it became apparent the system which the software is used may be set up to not allow a common user write access to a selected folder. If the selected folder does not have write permission, the code needs to prompt the user to select a different folder.

So far I have Labview 2012 and found the Get Permissions block under advanced file functions. Is this the best way to determine if a user has write permission? Does a better way exist to test for write permission?

MarcoM
  • 1,093
  • 9
  • 25
Agriculturist
  • 521
  • 9
  • 20

2 Answers2

3

Some people simply try to create a dummy file, handling the error and notifying it to the user if it's the case (and removing the dummy file if the creation succeeds).

Please note this is not a Labview related problem: give a look here on Stackoverflow and on a thread I've just started on NI Labview Forum.

Community
  • 1
  • 1
MarcoM
  • 1,093
  • 9
  • 25
2

Get Permissions does not return accurate results on Windows.

I just tried it on some subfolders of C:\Users on my Windows 7 machine and it returns 111111111 (binary) for all user folders - indicating that I should have full read and write access - even though Windows won't actually let me write to any user's folder other than my own.

Meanwhile C:\Users\Public returns 101101101, implying no write access, but I can write to that folder.

My understanding of Windows file and folder permissions in a network environment is that it can become very complex, with different policies applied in different places, and the best way to find out if you can write to a location is to try and write there and catch the error.

nekomatic
  • 5,988
  • 1
  • 20
  • 27
  • This oddball behavior is exactly what I was curious about. – Agriculturist Jun 13 '16 at 13:49
  • Thanks for pointing this out @nekomatic. I just updated my post. Apparently this problem is not only for Labview users: http://stackoverflow.com/questions/1281620/checking-for-directory-and-file-write-permissions-in-net – MarcoM Jun 14 '16 at 07:58
  • @MarcoM that's a good link, if only to illustrate that it's complicated - you should edit that into your answer! – nekomatic Jun 14 '16 at 12:16