Julian Carr Posted August 3, 2018 Share Posted August 3, 2018 Anyone know why this code: Procedure T; VAR s1 : STRING; BEGIN s1 := Concat(GetFolderPath(1), 'Test.txt'); ReWrite(s1); WriteLn('test'); Close(s1); END; Run(T); works fine on a Mac but returns this error on a PC: Error on line=6: T S1 - File operation returned error. Error on line=8: T S1 - Bad file name. C:\Program Files\Vectorworks 2018\Test.txt Thanks! Quote Link to comment
Nicolas Goutte Posted August 3, 2018 Share Posted August 3, 2018 The folder is probably write protected for a standard user. Quote Link to comment
Pat Stanford Posted August 3, 2018 Share Posted August 3, 2018 From the Function Reference Notes on GetFolderPath: Note that use of the negative values of these constants can be used to get the user-based folder path. The positive values are for application-based paths, which should not be used for writing. So try and see if you can get what you want with GetFolderPath(-1). Quote Link to comment
Sam Jones Posted August 4, 2018 Share Posted August 4, 2018 I think you need to specify a separater character. GetFolderPath() does not end in a ":" or a "\". You might try: IF Platform = 1 THEN sepChar := ':' ELSE sepChar := '/'; s1 := Concat(GetFolderPath(-1), sepChar, 'Test.txt'); I would share some code from my scripts, but they just collect file names; For example IF Platform = 1 THEN sepChar := ':' ELSE sepChar := '/'; cableCt := 0; index := 1; folderPath := CONCAT(GetFolderPath(-2), kMasterInventoryFolder, sepChar, kMultFileFolder); fileName := GetFilesInFolder(folderPath, index); WHILE (GetFilesInFolder(folderPath, index) <> '') DO BEGIN fileName := GetFilesInFolder(folderPath, index); suffix := COPY(fileName, LEN(fileName)-3, 4); IF COPY(fileName, LEN(fileName)-3, 4) = '.xml' THEN BEGIN cableCt := cableCt + 1; MultXMLList[cableCt] := fileName; END; index := index + 1; END; {WHILE (MultXMLList[index] <> '')} Quote Link to comment
Julian Carr Posted August 4, 2018 Author Share Posted August 4, 2018 Thanks guys. Nicolas: I am the admin user on both machines and if it works on a Mac then, should it not work on a PC? Still, maybe you are right. Pat: Message(GetFolderPath(-1)); also returns the path to application folder on Mac and PC. Sam: If you run Message(GetFolderPath(1)); you will see it does return a separator at the end of the path name. Quote Link to comment
Nicolas Goutte Posted August 6, 2018 Share Posted August 6, 2018 (edited) On 8/4/2018 at 6:48 AM, Julian Carr said: Thanks guys. Nicolas: I am the admin user on both machines and if it works on a Mac then, should it not work on a PC? Still, maybe you are right. I did a quick test in my Mac. I can create a file (from the command line, not from VW) in /Applications. However I cannot do the sampe in C:\Program Files on Windows. That is how both operating systems work. (Being an admin user on Windows, does not mean that unpriviledged programs like VW have admin rights to write files.) Edited August 6, 2018 by Nicolas Goutte Quote Link to comment
Julian Carr Posted August 6, 2018 Author Share Posted August 6, 2018 OK thanks for the confirmation Nicolas. Interesting that Vw can write to the Libraries folder though. I guess that's a slightly different mechanism though. Quote Link to comment
Nicolas Goutte Posted August 6, 2018 Share Posted August 6, 2018 I am not sure but I suppose that the installer makes the Library folder writable due to the library cache files. Quote Link to comment
WhoCanDo Posted August 23, 2018 Share Posted August 23, 2018 (edited) Hi Julian, My VW2018 on Windows 7 creates the text file without error. Could it be the Windows version tightening up security? Edited August 24, 2018 by WhoCanDo Clarification Quote Link to comment
Nicolas Goutte Posted September 3, 2018 Share Posted September 3, 2018 (edited) Sure that could be. I have my Windows always with "User Access Control" set at the maximum. (I have tested on WIndows 10 1803) Edited September 3, 2018 by Nicolas Goutte Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.