Jump to content

Display the user's machine directory and not the server's


FlavioMacedo

Recommended Posts

Good morning everyone.

 

The problem is this:

 

I installed the application where I have to present the directory tree of the client machine and I'm putting this in a treeview but it always mounts the directory tree where the application is running.

 

I need this tree to be the one of the client machine and not of the server.

 

Could someone help me with this problem? My code that mounts the memory table to show the directory looks like this:

 


procedure TMainForm.DirTreeChange(Sender: TObject; Node: TUniTreeNode);

var

   sr: TSearchRec;

   FileAttrs: Integer;

   theNode: TUniTreeNode;

begin

   FileAttrs := faDirectory;

   if (Node.Level = 0) then

      exit;

   if (Node.Level = 1) then

   begin

      Ni1 := 'c:\' + Node.text;

   end;

   if (Node.Level = 2) then

   begin

      Ni1 := 'C:\' + Node.Parent.text + '\' + Node.text;

   end;

   if (Node.Level = 3) then

   begin

      Ni1 := 'C:\' + Node.Parent.Parent.text + '\' + Node.Parent.text + '\' + Node.text;

   end;

 

...

...

...

 

   if (Node.Level = 12) then

   begin

      Ni1 := 'C:\' + Node.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.text + '\' +

             Node.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.text + '\' +

             Node.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.text + '\' +

             Node.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.text + '\' +

             Node.Parent.Parent.Parent.Parent.Parent.Parent.Parent.text + '\' +

             Node.Parent.Parent.Parent.Parent.Parent.Parent.text + '\' + Node.Parent.Parent.Parent.Parent.Parent.text +

             '\' + Node.Parent.Parent.Parent.Parent.text + '\' + Node.Parent.Parent.Parent.text + '\' +

             Node.Parent.Parent.text + '\' + Node.Parent.text + '\' + Node.text;

   end;

   MemData_Diretorio.Close;

   MemData_Diretorio.Open;

   if FindFirst(Ni1 + '\*.*', FileAttrs, sr) = 0 then

   begin

      repeat

         if (sr.Attr and FileAttrs) = sr.Attr then

         begin

            if ((sr.name <> '.') and (sr.name <> '..')) then

            begin

               if Node.Level = 0 then

               begin

                  theNode := DirTree.Items.AddChild(nil, sr.name);

               end

               else

               begin

                  theNode := DirTree.Items.AddChild(Node, sr.name);

               end;

               theNode.HasChildren := True;

            end;

         end

         else

         begin

            MemData_Diretorio.Insert;

            MemData_Diretorioupdate.AsBoolean := false;

            MemData_DiretorioArquivo.asstring := sr.name;

            MemData_DiretorioModificacao.asstring := FormatDateTime('dd/mm/yy hh:mm:ss', FileDateToDateTime(sr.Time));

            MemData_DiretorioTamanho.asstring := inttostr(sr.Size);

            MemData_Diretorio.Post;

         end;

      until FindNext(sr) <> 0;

      FindClose(sr);

   end;

 

end;

 


Thank you all for the help.

Thank you

Link to comment
Share on other sites

I'll try to explain it better.

 

I am making an application for managing files where the user has a treeview with the directory of his workstation and another one with the directories of the server.

 

The server is OK but the local machine where the user could get their files, drag and drop into the server directory.

 

In the location where the directory of the client machine should appear the server always appears. I am not able to direct the program to pick up the user's machine pastes so that it selects the file to upload.

 

It's more or less like a dropbox.

Link to comment
Share on other sites

Thanks for the answers but some more questions.

 

1) there is then some way of being able to select multiple files at a time to upload them all together. I'm trying to use it with unifileupload because I can only select 1 file at a time and would have to upload an entire directory.

 

2) How do I keep track of the upload progress of the files?

 

Thank you all for your help.

Link to comment
Share on other sites

I have already taken this example but at the time of compilation I get this error:
Fatal Error] ulsGlobal.pas (535): F2613 Unit 'Windows' not found.
Link to comment
Share on other sites

Please check

Tools->Library->paths

 

it seems paths are wrong

The path must be correct because the entire project is unigui including the examples are working correctly.
It must be something else.
The .pas file that is giving the error as I understand it is an Indy file. My indy is version 10 using with Delphi 10.1
Link to comment
Share on other sites

  • 2 weeks later...

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...