Where do I find a relative path? - path

I am trying to figure these out, but every single thing I read says exactly what I've already read in a previous article. I understand it theoretically, but I have no idea what how to write it into a code. I am such a noob and I need lots of help!

A relative path is the location of the file/folder relative to where you are. The absolute path is the full location. For example:
"C:\Product\Folder\SubFolder\file.exe" might be the absolute path of a file on your machine. But if you're already in C:\Product the relative path to that file would just be "Folder\SubFolder\file.exe". It's like knowing someone's full mailing address or knowing how to get to their house from yours. You may not need to know where you are in the world to know how to get from one place to another (your house to a coffee shop for example).
In code, you would use the absolute path if you're explicitly looking for a file at this location. But you may not always know the absolute location where your app is executing, and you are trying to access files that you control. In this case you only need to know how to get there based on where you are.
For example, My app may be installed at the following absolute paths "C:\Company\Product\app.exe" and my have had a library of files installed under that in the folder "C:\Company\Product\Files\". The absolute path may change if the user decides to install it in another location. But you still control the "Files" folder, so you would code the relative path of "Files\file.txt" to access it.
If you're still struggling with the difference. Think of the absolute path like the postal address of a chain store. Where every instance of that store is identical. The absolute path is the location of an item in a specific instance of that store (location of the store + location of item within the store). The relative path is just the location in the store. If the store were your app, or you were in a store, you don't really care where you are (which instance of the store you're in). You just need to know where the item is in the store. Relative path is knowing an item is in Row 2, second shelf from the bottom, third from the right. To you, it doesn't matter which store your in, you can still find it.

Related

Can I save the keep the absolute path of a file in database?

In my app I save some photos in sandbox and I keep its absolute path in database. Then I build and run again, I fetch the path and try to get the photo, it says the file doesn't exist.
At last, I found that every time I build and run my app, the path of app is different.
I use NSTemporaryDirectory() to get the temporary path, I run two times and get two results.
/private/var/mobile/Applications/80E09BB5-5FEB-4C27-935E-E29DE7861392/tmp/
/private/var/mobile/Applications/71427100-0DBF-42F0-B6B4-F88F6417292E/tmp/
Is it normal? When user updates my app, will the absolute path change?
If it's normal, should I just keep the relative path in database? Is there some best practice?
It's a very bad idea to store the absolute path in the database as any updates to the app results in the app being stored in a different folder within /private/var/mobile/Applications. During an app update, any files will be migrated across, however any references to them within the database will no longer be valid.
You must therefore always store the filepath relative to some other logical directory; for example the Documents or Caches folder.
This probably means you should store this path as a relative directory within your classes as well, and only resolve to an absolute path when you need to use it.
Finally storing temporary file references is probably a bad idea, as I believe any temporary or cached files can be removed from the filesystem by the O/S whenever it feels like it. Therefore you should store these files in the Documents folder, using the techniques I mentioned above.
You could save the file on server and store its physical path in database. I have built similar applications in past and that is how i used it. Might not be the right way but just a thought.
Is it normal?
Well, what is the meaning of temporary?
When user updates my app, will the absolute path change?
Well, what is the meaning of temporary?
If it's normal, should I just keep the relative path in database?
To do what with it?
Is there some best practice?
Don't use a temporary path for persistent storage. What about the documents folder?

Dropbox iOS SDK "Broken"?```

I am trying to use the latest official version of the DropBox iOS Core SDK, in particular the DBRestClient, to efficiently keep a document tree up to date on my local computer. However, several features of the SDK don't seem to be implemented as you'd expect, and I was wondering whether I am doing something wrong, failing to understand something, or on the other hand just looking for features that aren't there.
Dropbox has (at least?) two kinds of entities it stores: files and folders. If I make a change to a file in Dropbox, I can detect it by a change in the file's "rev" string.
However, for folders, the rev string doesn't change when the contents changes. For example, it doesn't change in response to any of the following:
Adding a file
Deleting a file
Editing a file
Question 1:
Is this the expected behavior ? If so, does that mean that when I want to know if any of my Dropbox files have changed I must walk through the entire folder tree every time ?
Deltas:
There is a command to get a "delta" of the current contents (of something, the command takes no path parameters) related a "cursor" string. The command looks like it is supposed to return a record of edited files/folders along with a new "cursor" string specifying the current state. However, when I get the delta, the contents are always empty. If I make a change in dropbox, and then send back the previous returned "cursor", I still get an empty delta.
Question 2:
Are deltas currently working in the SDK, and if so can anyone tell me what I am doing wrong ?
Question 1: Yes, that's the expected behavior. Typically you would use delta to watch for changes.
Question 2: Yes, I would assume that delta is working. You haven't shown any code, so it's impossible to guess what's going wrong.

RoR: Get file (attachment) name/location

In my app I want users to be able to associate a file(s) they have on their desktop/DropBox with a specific item, but I don't want/need them to be able to actually attach the file...I just want to get the file name and location and save that in my database. Then when I display the item I'll hyperlink to the location captured. Can someone point me to an example(s) of how to accomplish this? I looked at the JQuery File Upload (http://blueimp.github.com/jQuery-File-Upload/) but as I mentioned don't actually need to upload the file...so this should be something super easy.
Thanks for your time and assistance.
You can try and get value of file input, but you'll fail.
See this jsfiddle.
All I'm getting is the fake path
C:\fakepath\134.png
And there's certainly no C:\ drive on Mac OSX. :)
I guess, this is because of security restrictions. You shouldn't know (or care) about user's filesystem in a web app.

Absolute link to another workbook on the network

I currently have a excel workbook that has values being pulled from other workbooks in the same folder on the network.
Wherever this workbook is opened, the link to the workbook changes, and no longer works, as it stays relative to where you are opening it from. I need the path to point to the same place every time.
Example for where it should be pointing.
='\\1.1.1.1\intranet\lp\files\test\[metricsheet.xlsm]information'!$B$13
Is there a way to keep this path (absolute) without VBA?
Thanks!
='\\1.1.1.1\intranet\lp\files\test[metricsheet.xlsm]information'!$B$13
If the first part (1.1.1.1) is an ip address, you need two slashes. A single slash just refers to a directory, not a server.
Found out the issue. This path format does work.. however the relative path was matching the absolute path I wanted, as it was stored in the same folder. Moving it out and then copy/pasting the same path back in, caused it to stay.

How to set permission for Folder in Blackberry ?

I want to know how to set permission for folder that is created by my app so no one can delete or see that folder.
I think this is not 100% possible, however you may do smth in this direction. Check for FileConnection.setHidden(boolean), FileConnection.setWritable(boolean) and FileConnection.setReadable(boolean).
First of all, the API docs are vague as to whether those methods will have any effect at all on a specific device (meaning a file system).
Secondly, even if you use FileConnection.setHidden(boolean), then it is still possible for another app to "see" your file/dir by using FileConnection.list(String filter, boolean includeHidden). Once one has a path of you hidden dir, he/she can change the hidden attr (and other attrs), so it becomes visible/readable/killable.

Resources