How to store per-user temporary files? - delphi

I need to store some temporary files from my program sometimes, currently I use the AppData path which works. However, I have just been trying my program on a non Admin (guest) account on Windows. This is resulting in errors because Windows is refusing me access to the AppData folder.
What would be the most ideal path to use instead of AppData, that even a user with the lowest permissions can use?
I tried Googling this one because I am sure I have seen an article on the Microsoft website that lists the different paths and requirements needed but I can't find it.
Thanks

If you want to store temporary files then use a sub-folder in the temporary directory. Use GetTempPath to find out where this is.
Note that on all modern versions of Windows, this folder is a per-user folder and is not shared between different users. If you want a location that is shared between all users then you need the CSIDL_COMMON_APPDATA folder. However, as you have discovered, standard users do not have rights to write in the folder. The standard approach is for the installation program to create a sub-folder with a permissive ACL that allows sufficient write access for standard users.

Related

How to access files on Ceph directly as URL

I need a storage system with the following requirements:
1. It should support data/service clustering
2. It should be open-source so that I can extend functionalities later if needed
3. It should support file system because I want to access some files as public url(direct access). So that I can store my scripts in these files and directly refer these files.
4. Supports some kind of authentication
5. I want it to be on premise (Not cloud).
Ceph seems to qualify all the criteria but does it support the public access of files just like a URL(Point 3) ? It has ability to generate temporary URLs though but I want permanent URLs for few files.
You could run Nextcloud and have your data volume (and database, if you feel so inclined) stored on the Ceph cluster. That's open-source, you can setup direct links to files including permanent links, and is authenticated.

IDA Pro: Reverse-Engineering Temp Storage

In the executable I am reverse-engineering, there are several references to a path in my D:\ drive. However, I do not have a D:\ drive connected. Is it possible that it creates a temporary storage site in the executable?
For example, there is a string:
D:\BuildAgent\...\bin\...\fileIWantToSee.jpg
IDA even believes that the symbol information is in the D drive, and attempts to look for it, to no avail. There are many instances of file references within these strings, and many of them end with a:
Line: **LINENUMBER**
Where would I go about trying to find where this storage is located? Thank you!
EDIT: Could it be in a specific section?
Is it possible that it creates a temporary storage site in the executable?
This is possible. There exists at least one product (http://www.boxedapp.com/, kind of our competitor :) that lets the application create such container -- the calls to file APIs are intercepted by the code added to the application by this product, and this added code handles specific paths in a different way (emulating file operations), letting all other calls go to Windows API.

Delphi Database Connection to C:\ProgramFiles

I'm using the software Inno Setup in order to create an installer for my program, this installs the program to the C:\ProgramFiles(x86) folder, so Im linking my database connection to this new folder, however it won't let me link it as it says I don't have permission.
I am unsure of how to combat this error, as the database is the key part of my program and without it my program wont work.
Putting a database under C:\Program Files or C:\Program Files (x86) is not a good idea. Non-admin users don't have write access to those folder, and you should never give write access to it.
To be Windows conformant, you have two possibilities:
When your program starts the first time, copy a template database to the user's profile under %AppData%\companyname\prgname and use that from now on.
if you need different users to work on the same database, put the database under %ProgramData%\companyname\prgname instead, and don't forget to give user's write access to that folder.

Azure file storage/indexing solution

I'm developing a Web Application, and it is running as an Azure Web App. This application has a section in which a user can navigate a directory, and allows the user to open the files and browse sub-directories in said directory.
At the moment, the sub-directories and files are inside "~/Content/Documents", and I am browsing the directory's by using Directory.GetFiles() and Directory.GetDirectories(); functions which are provided by System.IO.
The files in question would be retrieved and downloaded several times a day, and there is no way to manually path one-by-one, seeing as there is a large quantity, and they are subject to change.
However, I has become inconvenient to store the files within the web directory. So my two questions are:
What Azure service can I use to store and retrieve my files?
and
Which of these services provides the ability to index/map a path, which would fit with my web-app?
Please note that the users do not have the ability to edit or otherwise upload any of the files, and there is therefor no need for the service to allow non-authenticated upload.
The newish Azure File Storage feature can be used to store files in Azure Storage and make them accessible via an SMB file share. This will allow for legacy application that require the use of a traditional file share for saving / retrieving files. This allows for easier integration into existing applications without needing to completely rewrite the file storage code.
https://azure.microsoft.com/en-us/blog/azure-file-storage-now-generally-available/

System.IO.IOException destroys session after RedirectToAction [duplicate]

I have a web app where the administrator can create news, pdf documents and other stuff in his cms panel.
The problem is when the admin delete a new or something else the app deletes all the files related to that new, I mean the images, pdfs and other documents. Tha main problem is those files are stored in folders under the "news" folder and when the app deletes them the session is lost.
How can I do to have a file system without losing the session?
I'd like that file system within the app folder...
Impossible for us to store those folders outside the app and we don't want to use StateServer because of the performanne....
Any other solution?
Thanks
Your session is lost becasue IIS recompiles. The easiest solution in my opinion is to store your files outside the wwwroot.
Discussed on SO: ASP.NET restarts when a folder is created, renamed or deleted
[Update]
Example:
Let's stay your app is in c:\inetpub\wwwoot\virtualdir1
You make a work directory:
c:\inetpub\inetwork
Give the proper rights (read/write/etc) to the Asp.net user of your app pool and it should all work like a charm.
More info on setting the rights: What are all the user accounts for IIS/ASP.NET and how do they differ?
Store the path to the workdirectory in your web.config (you no not want to hardcode it)
Having those files within the app folder is a poor desgin. The session is probably lost as you are causing IIS to recycle due to the file system changes. It is much safer to not have your web application able to write to its own folder, doing so is a security risk.
Separate your document folder and web site folder. And give right permission your document folder.

Resources