Currently I use the code below to compose the UNC-path of a folder.
Basically this is done once at initial setup of my application. The UNC-path is stored in the database and all other paths in the database point to this base-folder. Nothing can be saved/created outside this base-folder, so I only store the relative path to it.
So when the basefolder is set to: \\COMPUTERNAME\C$\FOLDERNA
and a file is stored in folder: \\COMPUTERNAME\C$\FOLDERNA
I only store the latter part of the filename: \MyFolder\MyFile.txt
Now the problem. If the administrator who is setting up my application is selecting/creating a base-folder (from within my application). Then this folder might not be shared. Normally this would not be a problem as long as the path isn't transferred to the UNC-path. From that moment on the folder isn't accessible anymore.
Created base-folder: C:\Foldername\Test\
Here folder "C:\Foldername\Test\" would be accessible to the admin, but folder "\\COMPUTERNAME\C$\Foldern
Apparently in order to access an UNC-path it must be shared first.
My customers are for some part, stand-alone users on one computer. They don't bother sharing folders (maybe even never heard of it). Others however need to work with multiple users in my application (they might even have a systemadministrator).
Another thing to keep in mind:
The computer of the customer needs the be set in a correct way, so sharing of folders is possible. I know f.e. that a missing registry-value called "IRPStackSize" can influence sharing folders.
So much for the background.
One possible approach could be to share the base-folder from within my application. The moment the base-folder is selected, it will be shared among all users.
What I would like from you is to come up with some workable solutions. After we agree upon the approach, then see what code is needed to make it happen.
function BuildUNCPath(vFolder : String) : String;
if Copy(vFolder,1,1) <> '\' then
Result := '\\' + GetComputerName + '\' + StringReplace(vFolder,':','$', [rfReplaceAll])
Result := vFolder;