Writing to a document's enclosing folder - objective-c

When you open an XCode project it can automatically write to the enclosing folder of the respective .xcodeproj file.
In a sandboxed application you can only write to files that are opened, or write to directories that have been opened with NSOpenPanel.
What I'm trying to achieve is the same functionality as XCode ; my app makes a project file (a document much like an .xcodeproj file) that is saved to a user-selected directory, and within that directory other files are created relating to that project file. However, if the file is re-opened after terminating the app, I end up losing permission to write to the enclosing directory.
I see bookmarks are an option but they do not provide the same functionality. If the project file is moved to a new directory it makes no sense to keep writing to the old directory, and I'd have to ask the user for permission to write to the new directory. I don't find this user-friendly. Is there absolutely no way to resolve this problem?

If the project file is moved to a new directory it makes no sense to keep writing to the old directory, and I'd have to ask the user for permission to write to the new directory. I don't find this user-friendly. Is there absolutely no way to resolve this problem?
Unfortunately for you this is Apple's sandbox model and you need to adapt to it. The process you describe is a good way to handle your situation - when you first create a project file ask the user to select the folder to store it and save a bookmark to that folder, when an existing project file is opened check whether you have a saved bookmark for its parent folder and if not put up a dialog explaining the file has been moved and ask the user for permission to use the new parent folder and keep a bookmark to it.
Users are used to these dialogs from apps, the sandbox has been around a long time. You might find keeping a number of saved bookmarks and optimising your collection will improve your users experience. E.g. remember that a bookmark to a folder grants access to all the files and folders within it, and the files/folders within those folders, etc. This means if a user reorganises by moving projects into sub folders may not require you to ask for a new bookmark, and similarly when a new bookmark is acquired any existing ones you have stored to folders contained by the new bookmark's folder are redundant and can be removed from your collection of stored bookmarks.
Not the answer you really wanted, but hope it helps!

Related

Is there an easy way to move a file to a different folder in dbt Cloud?

Is there an easy way to move a file to a different folder in dbt Cloud, without having to create a new file of the same name in the new folder, copy/paste from the old file, and delete the old file, which is a pain.
Is there a good reason I should NOT do this? I assume my refs still work as long as the filename remains the same, and I don't have any specific folder logic tied to this file.
For example, say I have my_model.sql in my 'staging' folder and I want to simply move it to my 'mart' folder instead. In this example I'd like to do this to reflect that my file is really a more 'stable' mart-type table file vs a staging view. I realize I can just change the materialization type, but I'm doing this more to organize things clearly. Thanks!
The way to move a file in the cloud IDE for dbt is not 100% obvious. You can use the rename function to move a file to another location.
Click on the drop down next to the file name, then select "Rename." That will open a file path and you can change where the file lives from there by typing in the new folder's name.
The easiest way I have found to do this is...not using DBT Cloud, but using github desktop (no command line needed).
Create a new branch
Open repository in github
View files in your file explorer
Move files or directory locally
Upload to github
Push to origin for the branch you created
Open a pull request
Merge
Depending on what the file or directory is you may find the creating a new branch and opening PR to be overkill. For my specific project there is a lot of legacy organization and models that we aren't totally sure don't have downstream dependencies, so creating a new branch for this allowed me to test run all of our models.
Hope this helps!

Vaadin 8 multiupload with folder selection

I need to upload files and folders to the server while preserving the hierarchy. At the moment I am using a plugin multiFileUpload that allows you to upload multiple files at the same time, but it ignores the selected folders. I know that neither vaadin nor Html5 has a universal solution that works everywhere for uploading folders.
I'm ready to write my own solution, but climbed the Internet can't find a way to display file selection (perhaps there will a JavaScript call) but the main question - is it possible somehow to POST a request Vaadin's and upload files by way of creating subfolders in which they were?
You can only upload files, not folders. It's simply not doable.
You can upload any number of files, but they won't be structured into folders.
I see two possibilities how you could still achieve what you need if you really wanted to, even if it changes the user experience a bit:
Let the user upload a .zip file of his folder structure. When they upload it, you unzip it on the server side and have now access to all the files in the correct folder structure.
Let the user upload all his files within his folder structure. After all files have been uploaded, You display all the files in a TreeGrid where the user can recreate the original structure using Drag-and-Drop or similar.

How to make files accessible to all users on Visual Basic app

I am attempting to make an instructional app for the call canter that I work at. Part of the code allows users to display information through the use of several files in our directory with drop down combo boxes.
For instance, a small portion of the code is similar to this (I did not save the app and bring it home so I am going off memory):
If cboGlossaryTerm.SelectedItem("MSN")Then
Process.Start("S:\MSN.pdf")
End If
I put the pdf files in My Resources and the Word files are added under the Solution folder.
I am using filepaths in the code as well.
(I attempted to save the pdf files in the Solutions folder but the pdf was not compatible.
With me adding the files this way, will users who do not have access to the S drive folder be able to display the files? Also, will the files remain accessible in the program if they are deleted from the S drive? If not, how should I be referencing the files in my project? Do I have to reference the pdf files from My Resources? If so, how do I do that in an If-Then statement similar to the one above?
from what you have there it doesn't look like the pdfs in the S:\ would be available to anyone who doesn't have the drive mapped on their local machine.
as for if the files are deleted, if they are being loaded from the S:\ then when they are deleted from there the program will not be able to find them to load them.
if the program is being installed on the local machines you might want to look at just including the pdfs in the installer and accessing them through the program files path.

Visual Studio 2010 Setup does not create added file

My problem should be plain and simple to solve, but google is not helping me today.
I need to read/write a configuration file (config.xml) and, as i see so much problems with permissions with special folders, i decided for myDocuments.
Now, from File system (Setup), I added a custom special folder (myDocuments)
added a subfolder (g1OKweb) inside myDocuments
added the file (config.xml) inside g1OKweb
What I expect, reading around, is that during the installation g1OKweb should be created if not existing or older, and the same for config.xml, but it isn't.
Does someone have any clue?
Thanks in advance
Use Directory.CreateDirectory to create the directory before attempting to access the file. This will automatically create all parts of the path that do not yet exist. If the full path already exists, it will do nothing.
When opening the file, use a FileStream constructor overload that allows you to specify FileMode.OpenOrCreate. This will succeed regardless of whether the file already exists or not.
When you have opened the file, check to see if it is empty before parsing it. If it is empty, insert your XML root element first.

Application Working Directory (VB.NET)

I am linking few excel and word files with my application. There is a predefined folder structure that holds all these files. i.e.
Base\Engineering\A.xlsx
Base\Sales\B.xlsx
and so on.
Now I want to link the "Base" folder with my application.
My current stupid solution is, to ask user to browse to the "Base" folder every time the application loads.
What is the most efficient way to do this?
In the end I want to create an installer for my application. I
wish to use Windows "Program Files" folder to host my folder
structure. This way users do not have to search for the "Base"
folder. How do I do this?
I am new to VB.NET.
You want the All Users Application Data folder:
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
There is also a per-User Application Data folder that you can reference. Which you need depends on what you're doing.