Solved

copying a file over the network

Posted on 2000-02-24
7
180 Views
Last Modified: 2010-04-04
Hi

I have an ap which needs to copy files from a cd rom to a folder on my local hard drive.  This works OK on my home PC, but at work on the network I get the error message "Directory does not exist".

I have done some experimenting to isolate the problem, and I have discovered that the error relates to a path with a space in the name - ie. w:\mar31_97\form files.  When I leave the "form files" bit out of it there is no error message.  Of course I tried formfi~1, but I still get the same error. I also tried to use a UNC path, but that failed too.

We are using NT SERVER 4, so it should be able to recognise long file names, shouldn't it?  The copy routine I am using is from fmxutils.pas, and I am using D4 Standard.

Any help would be much appreciated

Regards

John
0
Comment
Question by:jdthedj
7 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2555719
put the entire path between "
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2555720
Like "w:\mar31_97\form files"
0
 
LVL 3

Author Comment

by:jdthedj
ID: 2555728
Thanks for the reply Epsylon.  I have tried it, but that will not work either.

John
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
Fatman121898 earned 100 total points
ID: 2556997
Hi John,

I tried to copy files from one folder to another (I mean longname files) on NT4 SERVER, and it was allright.

The code I used is cutted from my old app:

 function CopyFiles(const FileSpec, NewPath:String; Move: Boolean): Boolean;
{Copies file or files}
  var
    FSearchRec: TSearchRec;
    Found: Integer;
    SomeFound, AllCopied, CurrentCopied: Boolean;
    AllErased, CurrentErased: Boolean;
  begin
    AllCopied:=True;
    AllErased:=True;
    Found:= FindFirst(PChar(FileSpec), faArchive, FSearchRec);
    SomeFound:=(Found=0);
     while Found = 0 do
       begin
         CurrentCopied:=CopyFile(PChar(ExtractFilePath(FileSpec)+FSearchRec.Name),
                            PChar(NewPath+FSearchRec.Name), False);
         AllCopied:=AllCopied AND CurrentCopied;
         if Move AND CurrentCopied
           then //delete file
             begin
               CurrentErased:=(DeleteFile(PChar(ExtractFilePath(FileSpec)+FSearchRec.Name)));
               AllErased:=AllErased AND CurrentErased;
             end;
         Found:=FindNext(FSearchRec);
       end;
    SysUtils.FindClose(FSearchRec);
    Result:=SomeFound AND AllCopied AND AllErased;
  end;

Hope helps.
Jo.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2557118
I don't know those fmxutils, but with the standard CopyFile API you'll have no problems to do what you want to do (we're doing this all day).

Regards, Madshi.
0
 
LVL 1

Expert Comment

by:Phoenix_s
ID: 2559137
fmxutils works GREAT with delphi 3

fmxutils and delphi 4.  yecchh

been there... hated it.

the standard copyfile does seem to be the one to use.
0
 
LVL 3

Author Comment

by:jdthedj
ID: 2559883
Hi Jo, Madshi and Phoenix S - thanks for the replies.  

I have tried Jo's code and it works, so I will accept that as an answer.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 184
delphi parse string to params 3 151
How to convert memory stream to PDF file 6 169
How to add columns to a RAD Studio FMX grid at design time 1 27
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question