Jump to content

I need to copy a file from outside the default folder of my unigui application


Recommended Posts

Posted

Hello,

I'm having the following problem to solve, if you can help me I'd be grateful:

I need to play .mp3 files that are on the same server that is running my DLL in Unigui, when I put the file inside the files folder it plays fine, but I need to get this file from another folder outside the files folder in a previous directory, as I do via Unigui, to copy this file from a folder outside the default folder that has the DLL.

My folder structure is as follows:

c:\musicas\ (which has my .mp3 files)

c:\my app\ (which has my DLL in Unigui)
I need to copy a certain .mp3 file from the folder c:\musicas\my.mp3 to the folder c:\my app\files

I can't do it, because from what I've noticed my application in Unigui only accepts copying from within the default folder where my application in Unigui is.

Is there any way I could copy the .mp3 file from an external folder (but within the same server) to my application's files folder?

 

Darlan Almeida.

Posted

Hello,

Yes, what you're trying to do is possible, but there are a few important details to keep in mind, especially regarding file access permissions and path handling in a UniGUI environment.

Since your application runs as a DLL under the web server, file system access is subject to the user permissions of the web server's process.


Make sure that the account under which your web server or UniGUI DLL runs (e.g., IUSR, NETWORK SERVICE, or your custom app pool identity in IIS) has read access to C:\musicas\ and write access to C:\my app\files\.

 

uses
  System.IOUtils, Winapi.Windows;

procedure CopyMp3File;
var
  SourceFile, DestFile: string;
begin
  SourceFile := 'C:\musicas\my.mp3';
  DestFile := UniServerModule.FilesFolderPath + 'my.mp3';

  if TFile.Exists(SourceFile) then
  begin
    if CopyFile(PChar(SourceFile), PChar(DestFile), False) then
      ShowMessage('File copied successfully!')
    else
      ShowMessage('Failed to copy the file.');
  end
  else
    ShowMessage('Source file not found.');
end;

 

  • Like 1
Posted

Hi, maybe you want to try another way without having to copy a file into the uniGUI application folder, namely by creating symbolic links on Windows OS, you can find out what symbolic links are. To create it, you can open Command Prompt with administrative privileges.

mklink /D <destination> <source>
mklink /D c:\myapp\mp3 c:\musicas\

 

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...