Solved

copying a file over the network

Posted on 2000-02-24
7
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

752 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