#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    5
    Rep Power
    0

    Copying file from local to SharePoint server location


    Now on my PC I can use explorer to open a location on our SP server (location eg ht tps : / / sp.myserver.com/site/Documents/). And from there I can copy/paste a file from eg my C:\ drive.

    I need to replicate the copy process progmatically. FileCopy() doesn't do it - seems to be the http:// bit that's causing problems I reckon?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    350
    Rep Power
    7
    I use INDY components to down load a file from a URL, perhaps it will solve your problem:
    Code:
    var
       URL: String;
       FS: TFileStream;
       IdHTTP: TIdHTTP;
       LocalFile: String;
    begin
       IdHTTP := TIdHTTP.Create(nil);
       try
          URL := 'https://sp.myserver.com/site/Documents/filetodownload.txt';
          LocalFile := 'C:\YourSaveFilePathHere\FileName.txt';
          FS := TFileStream.Create(LocalFile, fmCreate);
          try
             IdHTTP.Get(URL, FS);
          finally
             FS.Free;
          end;
       finally
          IdHTTP.Free;
       end;
    end;
    I have these units added to my uses clause:
    IdBaseComponent,
    IdComponent,
    IdTCPConnection,
    IdTCPClient,
    IdHTTP

IMN logo majestic logo threadwatch logo seochat tools logo