Share path between server and client (delphi) application - delphi

On my LAN I have 2 applications running in server/client mode developed with Delphi (but I don't think this is important).
On server PC (where run server application) there is a USB hard disk, this hard disk have many folder and subfolder shared on LAN.
Now I need to do this:
1. The server application must send to client application a shared folder (for example "d:\folder\subfolder\", then the client application must open this path to show the files (using explorer).
2. The user, using client application, must select a shared folder (for example "\SERVER\folder\subfolder\") and send this to server application, the server application must convert this path in local path (for example "d:\folder\subfolder\") and save it inside a database.
My problem is: is there a simple way to:
1. Convert the local path to remote path before send it to client se the client can open it easily?
2. Convert the remote path to local path before save it inside database.
NOTE: the main folder or main drive of shared hard disk can be change.
NOTE2: I'd like use IP address and not windows pc name if possible because it can be change.
I hope I explained.
Thanks

If I understand you correctly you want to acces some files that are inside some shared folder. Right?
If that is true then go and acces to these files unsing the network path which is formed in this manner
\\Networkedcomputer\SharedFolderName\Subfolder\...
where:
NetworkComputer is either a name of computer that is sharing that folder or its IP adress. I asume you are interested in using of IP adresses since you already have acces to that information from your other networked components.
SharedFolderName is the network name that was chosen when specific filder was set to be shared on the network. This name doesen't even have to be the same as the name of actual folder
Subolder can be any subfolder of the share folder
In order to get networked path to your shared folder you do need to know network name of the shared folder.
Perhaps you could even retrieve this information from SelectDirectory method which shows special dialog for selecting of directory, but I'm not sure if it does support networked folders. If not you could make use of OpenDialog.
NOTE: In any case when selecting the shared folder either with the use of SelectDirectory or OpenDialog you would need to go to that folder through Network Places (Network -> MyComputerName) and not directly through MyComputer.
But if you need to aquire the shared name for any local folder programatically I think you would have to go and read that information from registry as I'm not sure there is a specific API call for this.
EDIT: The answer on SO question below refers to several Delphi components that can be used for managing of Shared network resources. So I guess you could use to retrieve the network path for a shared local folder but I haven't tried them out.
How do I remotely obtain a system's network shares and connections?

Related

Unrecognized property 'CommType' in connection string using Advantage Data Provider with Entity Framework

I'm trying to set CommType in connection string for Advantage DataBase Server using Entity Framework 5 and Advantage Data Provider in a .NET Web Application.
Connection string is in properties.config file.
I trie to use ads.ini but I don't know where to put it (I try in wwwroot/site/bin but nothing happened)
I need to set this parameters:
RETRY_ADS_CONNECTS = 5
PACKET_SIZE=512
USE_TCP_IP = 1
I can do this whiteout errors, but not using properties.config file.
AdsConnection conn = new AdsConnection("data source=\\\\SERVER1\\DATA; ServerType=remote;TableType=CDX;CommType = TCP_IP");
Any clue about how to solve this? Using ADS.INI or properties.config file, same for me.
Thank you!
Gaston Brave.
You can use the ADS.INI file for this purpose. Where it needs to be located (or how to tell Advantage where to find it) depends on the OS you're using.
From the Advantage Help file topic ADS.INI:
Windows
In order for the ads.ini file to be used, it must be located in the application directory, the Windows directory, the Windows System directory, or the client's search path.
In addition, if an environment variable exists with the name adsini_path, that path will be used to locate the ads.ini file. This can be helpful when you do not want to modify the application’s search path, but still need the ads.ini file to exist in a directory multiple users have rights to (for example on Windows Vista installations). An application can often set the environment variable at run-time before calling any Advantage functions, which avoids the need to set a per-workstation environment variable.
Linux
In order for the ads.ini file to be used, it must be located in the application directory, a directory specified in an environment variable named ADSPATH, in the users home directory, or in the /etc directory. If located in the users home directory the ads.ini file should be named .ads.ini (note the initial "dot").

How to allow other machines in same LAN (PC/Mac/Mobile Devices) to download from our Electron app?

The question is weird but it’s because I don’t even have any knowledge about this concept.
Here is the thing:
I’m working with an Electron app that is a whiteboard application.
A user can draw something onto the board and export it to PDF.
This PDF will be saved into a folder (I assume AppData folder on Windows or something like that on MacOS), so that other machines can access (download) it.
Now I don’t know how to allow other machines to download this file.
Normally we will need to share the folder (on Windows), and other machines can go to Networks/our-machine to find and download the shared files.
But the owner of this app said that we can download it if both machines are on the same LAN, using some kind of URL like 192.168.x.x:6554/mypdfile_somerandomid.pdf
(this URL can then be turned into a QR code so that mobile devices can use camera to access the link quickly)
I don’t know how is this possible. Can you please suggest some solutions?
Thank you very much
Writing URLs
A URL, or uniform resource locator, is a form of address that refers
to a location or file on a network. The address is formatted like
this:
scheme://servername.example.com/folder
The scheme specifies the protocol or type of server. The example.com
portion of the address is called the domain name. If a username is
required, it is inserted before the server name:
scheme://username#servername.example.com/folder
Some schemes require the port number to be specified. Insert it after
the domain name:
scheme://servername.example.com:port/folder
Without public share that windows offers, you will need other third party software to accomplish what you want, which will do the same as windows does.
Better just share the folder your Electron app uses to export PDFs.

How to share files between multiple ASP.NET MVC Applications?

I have two web application in my solution. One of them is for managing the system and another is for clients.
I should publish them one by one in separated places (of course on a machine but in separated addresses for Example http://manager.com and http://clients.com)
My question here is that, can clients web application access the files that the other manager web application has (in its physical directory)? If not how can I approach this problem?
see this design to get more details for this problem :
Thanks!
What I usually do in a scenario like this, is store the files in a folder in the application that does the writing. Then I use IIS to create a virtual directory in the other application that points to the folder containing the files in the first application.
So in your case, you could have a folder "Files" in the manager.com website. Let's say the folder has this full path: D:\Websites\manager.com\Files You can then create a virtual directory in the clients.com website pointing to that path.
This has the advantage that you can code everything as if the folder exists in both applications.
If your applications placed on one machine - certainly can.
You should do only one thing - give permission to folder with files (Or permission to DB with files) to user that run your web application on web server (Usually IIS if you use MVC < 5)
It seems from your comment that you want to share uploaded files between multiple web project. You can store them in a common folder outside your web project folder.
For example, create a folder in
"C:\Temp\" say "SharedFiles".
The manager web application that receives the file from user (through upload) can store the files in this folder. The client web application can refer this location for file while reading.
You may have to give permission to the user (IIS_IUSRS) to access this folder.

How to find out the name of the common documents folder on a network machine

Given that I am executing an EXE file (D2006 app) on a machine across the network, how can I get the pathname to the commondocs folder on that machine, given that the EXE might have been invoked from a UNC shortcut or a mapped drive letter shortcut, and the platform of the remote machine is not necessarily known (but will be >= WinXP)?
The situation is where the client has a large number of dispersed machines, and they can't be bothered installing my app on all the PC's. So what they do is install the executable somewhere on the network and give everybody a shortcut to that. This already seems to suit them fine and there are no issues there.
At their request, I made the app read the settings from an INI file placed in the same folder as the executable. I can only assume they have configured things so that all the users can write to that folder so that the INI file can be saved back.
However, I want to change it so that the INI file is read and saved to somewhere in the commondocs folder tree on the remote machine, so that they don't need to provide write access to a Program files folder.
The machine that's running your program is the only machine you have access to. The machine where your program is stored is irrelevant. It's just a disk drive. It might not be running Windows. It might even be a NAS that's hardly running anything at all.
If the customer wants the common-documents folder of the file server to act as the common-documents folder for everyone on all the client systems, then get the sysadmin to configure a shared folder on the server and then configure the clients to use that remote folder as their common-documents folder. There is no special programming required on your part for that.
To get the common-documents folder of the machine your program is running on, you can call any of various API functions, including ShGetFolderPath. The CSIDL value you need is CSIDL_COMMON_DOCUMENTS. If you call SHGetKnownFolderPath instead, use FOLDERID_PublicDocuments.

Does Windows.CopyFile create a temporary local file while source and destination are network shares?

I have a D2007 application that uses Windows.CopyFile to copy MS Word and PowerPoint files from one network folder to another network folder. Our organization is migrating to Windows 7 from Vista. One of my migrated users got an error message that displayed a partial local folder (C:\Users\(username)\...\A100203.doc) during the copy. Does the CopyFile function cache a local copy of the document when it is copying from one network folder to another network folder or is it a direct write? I have never seen this error before and the application has been running for years on Win95, Win 98, Win2000, WinXP and Vista.
Windows.CopyFile does NOT cache the file on your hard drive... instead, it instructs Windows to handle the copying of the file itself (rather than you managing the streams in your own program). The output file buffer (destination) is opened, and the input buffer simply read and written. Essentially this means that the source file is spooled into system memory, then offloaded onto the destination... at no point is an additional cache file created (this would slow file copying down).
You need to provide more specific information about your error... such as either the text or an actual screenshot of the offending error message. This will allow people to provide more useful answers.
The user that launches the copy will require read access to the original and write access to the target, regardless of caching (if the user has read access to the file, then the file can be written to a local cache, so caching/no-caching is irrelevant).
It's basic security to disallow someone to be able to copy files/directories among machines just because the security attributes between the machines are compatible.
There's little else to say without the complete text of the error message.

Resources