Discussion:
Error by creating a file in a folder
Claudius Sailer
2017-10-30 18:43:21 UTC
Permalink
Hello,

a customer of my application (MacOS X) has the following problem with a new version. The older application works fine and I doesn’t change anything of this part of the application.

When he starts my application the application try to create a file „Voreinstellungen.xml“ in the same directory where the application is. but he gets an error message that the application can’t create the file or can’t open the file.

this is my code

Dim g as FolderItem

if NOT PrefsWerdenGeladen then
PrefsWerdenGeladen=true

g=GetFolderItem(PrefsDatei)
MsgBox g.AbsolutePath + " " + g.Name + " " + g.Permissions.ToText
if g<> nil and g.iswriteable and NOT g.locked then
If PrefDic.SaveXML(g, False) Then
// Saved
Else
MsgBox "Error saving XML"
End If
elseif g=nil then
//allgemeines Problem
Fehlermeldung(TextFehler003a + PrefsDatei + TextFehler003c)
elseif NOT g.iswriteable then
//Datei ist schreibgeschuetzt oder schon in Benutzung
Fehlermeldung(TextFehler003a + PrefsDatei + TextFehler003b + " (is not writable)")
elseif g.Locked then
//Datei ist schreibgeschuetzt oder schon in Benutzung
Fehlermeldung(TextFehler003a + PrefsDatei + TextFehler003b + " (locked)")
end if

PrefsWerdenGeladen=false
end if

the MsgBox is new testing Code. At the moment I have no screenshot of this. I am waiting for response from my customer.
PrefsDatei is only a string „Voreinstellungen.xml"

do you have any idea where this is coming from and how I can fix this. I have on all of my Computers nowhere this problem and the user sends me screenshots where I can see that permissions are read and write for his user to the folder and the files in this folder. When he copies the Voreinstellungen.xml file in the folder to the Application he catches the same error message but the file has also the permissions read and write for him.

thanks for ideas and help. It would be great also when you have some ideas what code I could add to make testing and finding the problem easier.

It is so difficult to find a solution, when the problem is not reproducible ob my computer.
When I get more informations/feedback I will add it to this post.


Claudius


To unsubscribe, email ***@xojo.com
Jon Ogden
2017-10-30 19:29:55 UTC
Permalink
First of all, you should never create a file in the folder where the application resides. That is asking for trouble as you may not have write permissions there and he likely doesn’t. It’s possible he updated his OS recently.

Files for the app should be created in ~/Library/Application Support if it is user specific or /Library/Application Support for global settings.

Why it works with an older version of your app and not with the newer, version, I am not sure. Getting debugging data from your customer would be helpful. But the first step I would do is not create the Xml file in the same directory as the app.

Regards,

Jon
Post by Claudius Sailer
Hello,
a customer of my application (MacOS X) has the following problem with a new version. The older application works fine and I doesn’t change anything of this part of the application.
When he starts my application the application try to create a file „Voreinstellungen.xml“ in the same directory where the application is. but he gets an error message that the application can’t create the file or can’t open the file.
this is my code
Dim g as FolderItem
if NOT PrefsWerdenGeladen then
PrefsWerdenGeladen=true
g=GetFolderItem(PrefsDatei)
MsgBox g.AbsolutePath + " " + g.Name + " " + g.Permissions.ToText
if g<> nil and g.iswriteable and NOT g.locked then
If PrefDic.SaveXML(g, False) Then
// Saved
Else
MsgBox "Error saving XML"
End If
elseif g=nil then
//allgemeines Problem
Fehlermeldung(TextFehler003a + PrefsDatei + TextFehler003c)
elseif NOT g.iswriteable then
//Datei ist schreibgeschuetzt oder schon in Benutzung
Fehlermeldung(TextFehler003a + PrefsDatei + TextFehler003b + " (is not writable)")
elseif g.Locked then
//Datei ist schreibgeschuetzt oder schon in Benutzung
Fehlermeldung(TextFehler003a + PrefsDatei + TextFehler003b + " (locked)")
end if
PrefsWerdenGeladen=false
end if
the MsgBox is new testing Code. At the moment I have no screenshot of this. I am waiting for response from my customer.
PrefsDatei is only a string „Voreinstellungen.xml"
do you have any idea where this is coming from and how I can fix this. I have on all of my Computers nowhere this problem and the user sends me screenshots where I can see that permissions are read and write for his user to the folder and the files in this folder. When he copies the Voreinstellungen.xml file in the folder to the Application he catches the same error message but the file has also the permissions read and write for him.
thanks for ideas and help. It would be great also when you have some ideas what code I could add to make testing and finding the problem easier.
It is so difficult to find a solution, when the problem is not reproducible ob my computer.
When I get more informations/feedback I will add it to this post.
Claudius
To unsubscribe, email ***@xojo.com
Jerry Fritschle
2017-10-30 19:42:14 UTC
Permalink
When he starts my application the application try to create a file „Voreinstellungen.xml“ in the same directory where the application is. but he gets an error message that the application can’t create the file or can’t open the file.
Just off the top of my head, I would put a file like this in a folder in SpecialFolder.ApplicationData (which maps to ~/Library/Application Support on Mac), instead of the app’s own folder.

Does your application reside in the Applications folder?


-----
"Drama is life with the dull bits cut out."
-Alfred Hitchcock

Jerry Fritschle
***@icloud.com






To unsubscribe, email ***@xojo.com
Claudius Sailer
2017-10-30 22:34:01 UTC
Permalink
this is old old old stuff from Time when RB is published first time. I Never changed that 🙈🙈🙈

The App comes in a folder and the complete folder will be installed/copied to the place where I want it. I know not the correct way like guide lines 😉
Post by Jerry Fritschle
When he starts my application the application try to create a file „Voreinstellungen.xml“ in the same directory where the application is. but he gets an error message that the application can’t create the file or can’t open the file.
Just off the top of my head, I would put a file like this in a folder in SpecialFolder.ApplicationData (which maps to ~/Library/Application Support on Mac), instead of the app’s own folder.
Does your application reside in the Applications folder?
-----
"Drama is life with the dull bits cut out."
-Alfred Hitchcock
Jerry Fritschle
To unsubscribe, email ***@xojo.com
vaughnsc .
2017-10-31 03:03:03 UTC
Permalink
(As I understand it):

Regardless of when the code was written, the behavior will change based on
whick SDK Xojo targets at build time.

For example if you use a version of RB that targeted the 10.4 SDK and you
run the app on 10.8, the OS may cut some slack (grandfathered)

Build the same project in a newer Xojo and the OS may halt the same
operation in its tracks (e.g. for stuff such as sandboxing). Target a newer
SDK and you must play by it's rules.

When you see a release note say that an older OS version was dropped, it
probably means the SDK was changed to gain new features.

So it really boils down to what OS was targeted behind-the-scenes when the
app was built.

Hope this prevents some head-scratching.

Vaughn
Post by Claudius Sailer
this is old old old stuff from Time when RB is published first time. I
Never changed that 🙈🙈🙈
The App comes in a folder and the complete folder will be installed/copied
to the place where I want it. I know not the correct way like guide lines 😉
When he starts my application the application try to create a file
„Voreinstellungen.xml“ in the same directory where the application is. but
he gets an error message that the application can’t create the file or
can’t open the file.
Just off the top of my head, I would put a file like this in a folder in
SpecialFolder.ApplicationData (which maps to ~/Library/Application Support
on Mac), instead of the app’s own folder.
Does your application reside in the Applications folder?
-----
"Drama is life with the dull bits cut out."
-Alfred Hitchcock
Jerry Fritschle
To unsubscribe, email ***@xojo.com

Continue reading on narkive:
Loading...