CSOM code in C # to download and upload multiple files from/to sharepoint library

Hi All,
Please help me I want to first download all my files from sharepoint library to my local folder using CSOM code .
Once downloading is completed I want to upload those files in another library .
I have done same thing using web services but need to do by CSOM now.
Thanks please provide code of peice
sudhanshu sharma Do good and cast it into river :)

By using below code I am downloading multiple documents and uploading same doc to sharepoint while uploading i want to updat emetadata of source library to destination library ..
I am able to do so but want to do now for dateandTime+metadata column as well please can you check my approach and let me know tht how to do for such kind of columns-
FileProperty.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ST_9569f2fe51bd4137bb31c38b3d46455d
class FileProperty
public string Title; //single line of text
public string Description; //Multiple line of text
public string DocumentType; //choice type
public string DocumentCategory; //Choice type
public string DocumentNumber; //Single line of text
// public string DocumentStatus; //Choice
public string DocumentTitle; //single line of text
// public string CrossReference; //Multipleline type
//public DateTime PublishDate; //DateAndTime Type column
/// <summary>
/// Get the SP Document Column internal name and thier respective values
/// in key -value pair.
/// </summary>
/// <returns>The List of KeyValuePair</returns>
public List<KeyValuePair<string, string>> getColumnKeyValueListProducts()
{//Target Columns
List<KeyValuePair<string, string>> columnKeyValuePairList = new List<KeyValuePair<string, string>>();
columnKeyValuePairList.Add(new KeyValuePair<string, string>("Title", Title));
columnKeyValuePairList.Add(new KeyValuePair<string, string>("Description0", Description));
columnKeyValuePairList.Add(new KeyValuePair<string, string>("Document_x0020_Type", DocumentType));
columnKeyValuePairList.Add(new KeyValuePair<string, string>("Document_x0020_Category", DocumentCategory));
columnKeyValuePairList.Add(new KeyValuePair<string, string>("Document_x0020_Number", DocumentNumber));
//columnKeyValuePairList.Add(new KeyValuePair<string, string>("Document_x0020_Status", DocumentStatus));
columnKeyValuePairList.Add(new KeyValuePair<string, string>("Document_x0020_Title", DocumentTitle));
//columnKeyValuePairList.Add(new KeyValuePair<string, string>("Cross%5Fx0020%5FReference", CrossReference));
// columnKeyValuePairList.Add(new KeyValuePair<string, string>("Publish_x0020_Date", PublishDate));
return columnKeyValuePairList;
/* public List<KeyValuePair<string, DateTime>> getColumnKeyValueListProductsforDatenTime()
//Target Columns
List<KeyValuePair<string, DateTime>> columnKeyValuePairListdt = new List<KeyValuePair<string, DateTime>>();
columnKeyValuePairListdt.Add(new KeyValuePair<string, DateTime>("Publish_x0020_Date", PublishDate));
return columnKeyValuePairListdt;
#region Help: Introduction to the script task
/* The Script Task allows you to perform virtually any operation that can be accomplished in
* a .Net application within the context of an Integration Services control flow.
* Expand the other regions which have "Help" prefixes for examples of specific ways to use
* Integration Services features within this script task. */
#endregion
#region Namespaces
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using Microsoft.SharePoint.Client;
using System.IO;
using System.Net;
using System.Collections.Generic;
//using System.IO;
#endregion
namespace ST_9569f2fe51bd4137bb31c38b3d46455d
/// <summary>
/// ScriptMain is the entry point class of the script. Do not change the name, attributes,
/// or parent of this class.
/// </summary>
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
#region Help: Using Integration Services variables and parameters in a script
/* To use a variable in this script, first ensure that the variable has been added to
* either the list contained in the ReadOnlyVariables property or the list contained in
* the ReadWriteVariables property of this script task, according to whether or not your
* code needs to write to the variable. To add the variable, save this script, close this instance of
* Visual Studio, and update the ReadOnlyVariables and
* ReadWriteVariables properties in the Script Transformation Editor window.
* To use a parameter in this script, follow the same steps. Parameters are always read-only.
* Example of reading from a variable:
* DateTime startTime = (DateTime) Dts.Variables["System::StartTime"].Value;
* Example of writing to a variable:
* Dts.Variables["User::myStringVariable"].Value = "new value";
* Example of reading from a package parameter:
* int batchId = (int) Dts.Variables["$Package::batchId"].Value;
* Example of reading from a project parameter:
* int batchId = (int) Dts.Variables["$Project::batchId"].Value;
* Example of reading from a sensitive project parameter:
* int batchId = (int) Dts.Variables["$Project::batchId"].GetSensitiveValue();
#endregion
#region Help: Firing Integration Services events from a script
/* This script task can fire events for logging purposes.
* Example of firing an error event:
* Dts.Events.FireError(18, "Process Values", "Bad value", "", 0);
* Example of firing an information event:
* Dts.Events.FireInformation(3, "Process Values", "Processing has started", "", 0, ref fireAgain)
* Example of firing a warning event:
* Dts.Events.FireWarning(14, "Process Values", "No values received for input", "", 0);
#endregion
#region Help: Using Integration Services connection managers in a script
/* Some types of connection managers can be used in this script task. See the topic
* "Working with Connection Managers Programatically" for details.
* Example of using an ADO.Net connection manager:
* object rawConnection = Dts.Connections["Sales DB"].AcquireConnection(Dts.Transaction);
* SqlConnection myADONETConnection = (SqlConnection)rawConnection;
* //Use the connection in some code here, then release the connection
* Dts.Connections["Sales DB"].ReleaseConnection(rawConnection);
* Example of using a File connection manager
* object rawConnection = Dts.Connections["Prices.zip"].AcquireConnection(Dts.Transaction);
* string filePath = (string)rawConnection;
* //Use the connection in some code here, then release the connection
* Dts.Connections["Prices.zip"].ReleaseConnection(rawConnection);
#endregion
/// <summary>
/// This method is called when this script task executes in the control flow.
/// Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
/// To open Help, press F1.
/// </summary>
public void Main()
// TODO: Add your code here
//Unpublished lib used to download files from sharepoint to local and Published library for uploading files from local to sharepoint
//var srcFolderUrl = "http://ui3dats011x:2015/sites/techunits/UnPublished%20Doc/Forms/AllItems.aspx";
//var destFolderUrl = "http://ui3dats011x:2015/sites/techunits/Published%20Documents/Forms/AllItems.aspx";
using (var ctx = new ClientContext("http://ui3dats011x:2015/sites/techunits/"))
try
List LibraryName = ctx.Web.Lists.GetByTitle("Unpublished Doc");
List LibraryName1 = ctx.Web.Lists.GetByTitle("Published Documents");
ctx.Load(LibraryName1.RootFolder);
ctx.Load(LibraryName);
ctx.ExecuteQuery();
CamlQuery camlQuery = new CamlQuery();
//Used this caml query for filtering
camlQuery.ViewXml = @"<View><Query><Where><Eq><FieldRef Name='Document_x0020_Type'/><Value Type='Choice'>Technical Unit</Value></Eq></Where></Query></View>";
Microsoft.SharePoint.Client.ListItemCollection listItems = LibraryName.GetItems(camlQuery);
ctx.Load<Microsoft.SharePoint.Client.ListItemCollection>(listItems);
ctx.ExecuteQuery();
string filename;
FileInformation fileInfo;
System.IO.FileStream outputStream;
Dictionary<string, string> itemmetadata = new Dictionary<string, string>();
foreach (var item in listItems)
if (itemmetadata.Count > 0)
itemmetadata.Clear();
ctx.Load(item);
ctx.ExecuteQuery();
ctx.Load(item.File);
ctx.ExecuteQuery();
filename = item.File.Name;
foreach (KeyValuePair<string, object> metaval in item.FieldValues.)
string metavalue = Convert.ToString(metaval.Value);
//if(String.IsNullOrEmpty(metaval.Value.ToString()))
if (!(String.IsNullOrEmpty(metavalue)))
itemmetadata.Add(metaval.Key, metaval.Value.ToString());
else
itemmetadata.Add(metaval.Key, "");
fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ctx, item.File.ServerRelativeUrl.ToString());
outputStream = new FileStream(@"C:\Users\jainruc\Desktop\Sudhanshu\ComDownload\" + filename, FileMode.Create, FileAccess.Write);
fileInfo.Stream.CopyTo(outputStream);
outputStream.Dispose();
outputStream.Close();
//Uploading
string srcpath = @"C:\Users\jainruc\Desktop\Sudhanshu\ComDownload\";
string siteName = @"http://ui3dats011x:2015/sites/techunits/";
string docLibraryName = @"http://ui3dats011x:2015/sites/techunits/Published%20Documents/Forms/AllItems.aspx";
UploadFile(srcpath, siteName, docLibraryName, itemmetadata,filename);
}//End of try
catch (Exception ex)
Dts.TaskResult = (int)ScriptResults.Success;
public void UploadFile(string srcpath, string siteName, string docLibraryName,Dictionary<string,string> metavalue,string filename)
using (ClientContext ctx = new ClientContext("http://ui3dats011x:2015/sites/techunits/"))
try
List LibraryName1 = ctx.Web.Lists.GetByTitle("Published Documents");
ctx.Load(LibraryName1.RootFolder);
ctx.Load(LibraryName1);
ctx.ExecuteQuery();
ctx.Credentials = new NetworkCredential("jainfgfgh", "Pashg8878", "mydomain");
//Loop for getting all files one by one
using (var fs = new FileStream(String.Concat(srcpath,"/",filename), FileMode.OpenOrCreate))
string fileUrl = String.Format("{0}/{1}", LibraryName1.RootFolder.ServerRelativeUrl, filename);
Microsoft.SharePoint.Client.File.SaveBinaryDirect(ctx, fileUrl, fs, true);
UpdateMetadata(fileUrl,ctx,metavalue);
//End of looping
}//End of try block
catch (Exception ex)
}//End of Using
}//End of function
public void UpdateMetadata(string uploadedfileurl,ClientContext ctx,Dictionary<string,string> mvalue)
Microsoft.SharePoint.Client.File uploadedfile = ctx.Web.GetFileByServerRelativeUrl(uploadedfileurl);
//create an object of the class holding all the properties of the document
ctx.Load(uploadedfile);
ctx.ExecuteQuery();
FileProperty fileProperty = new FileProperty();
fileProperty.Description = mvalue["Description0"];
fileProperty.Title = mvalue["Title"];
fileProperty.DocumentType = mvalue["Document_x0020_Type"];
fileProperty.DocumentCategory = mvalue["DocumentCategory"];
fileProperty.DocumentNumber = mvalue["DocumentNumber"];
fileProperty.DocumentTitle = mvalue["DocumentTitle"];
//fileProperty.PublishDate = Convert.ToDateTime(mvalue["PublishDate"]);
// fileProperty.DocumentStatus = mvalue["DocumentStatus"];
List<KeyValuePair<string, string>> columnKeyValueList;
//create a list of item need to be updated or added to sharepoint library
List<FileProperty> propertyList = new List<FileProperty>();
propertyList.Add(fileProperty);
columnKeyValueList = fileProperty.getColumnKeyValueListProducts();
ListItem item = uploadedfile.ListItemAllFields;
foreach (KeyValuePair<string, string> metadataitem in columnKeyValueList)
item[metadataitem.Key.ToString()] = metadataitem.Value.ToString();
//item["Title"] = uploadedfile.Title;
item.Update();
ctx.Load(item);
ctx.ExecuteQuery();
#region ScriptResults declaration
/// <summary>
/// This enum provides a convenient shorthand within the scope of this class for setting the
/// result of the script.
/// This code was generated automatically.
/// </summary>
enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
#endregion
sudhanshu sharma Do good and cast it into river :)

Similar Messages

  • I recently updated my macbook, i don't know if that has any effect to my recent problem, but when i try to download and save .mp3 files from the internet, like i have done in the past, it downloads but not as an mp3 file, its "blank"

    i recently updated my macbook, i don't know if that has any effect to my recent problem, but when i try to download and save .mp3 files from the internet, like i have done in the past, it downloads but not as an mp3 file, its "blank" and when i try to open it, i can't? I NEED HELP !

    Here is the download page

  • Download and upload of file to server dir (AL11)

    Hello,
    I have a custom program that is downloading files from application server directory (they are like templates) to user local pc. User is then modifying such files and finally upload them in another AS directory.
    The program is currently making use of FM's C13Z_FILE_DOWNLOAD_BINARY and  C13Z_FILE_UPLOAD_BINARY.
    There was no problem until hot packages have been implemented: now such FM's are returning an error saying:
    Internal program error; (YDOWNLOAD SAPLC13Z 0 C13Z_RAWDATA_WRITE)
    When in debug, it appears that the FM C13Z_RAWDATA_WRITE (called by the above mentioned FM's) is checking the calling program (sy-cprog) and if this latter is not within a list of standard programs (hardcoded), then the error is thrown.
    My question is: Is there another way to download and upload files without such error? Could you please share the code?
    Thanks a lot for help and suggestions!
    Best regards,
    JFlanders

    Hello,
    Please see note   1809258 - Internal program error; ( <program name> SAPLC13Z 0 C13Z_RAWDATA_READ )
    A possibile solution is to use cl_gui_frontend_services class methods like gui_download and gui_upload, for instance:
    TYPES: t_line(1) type x.
    DATA: i_tab TYPE STANDARD TABLE OF t_line,
        i_wa(1) type x.
    OPEN DATASET lv_file_appl FOR INPUT IN BINARY MODE.
    DO.
      CLEAR i_wa.
      READ DATASET lv_file_appl INTO i_wa.
      IF SY-SUBRC <> 0.
        EXIT.
      ELSE.
        APPEND i_wa TO i_tab.
      ENDIF.
    ENDDO.
    CLOSE DATASET lv_file_appl.
    DATA: lv_fn TYPE string.
    lv_fn = lv_file_name.
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        filename                = lv_fn
        filetype                = 'BIN'
        append                  = ' '
      CHANGING
        data_tab                = i_tab
      EXCEPTIONS
        file_write_error        = 1
        no_batch                = 2
        gui_refuse_filetransfer = 3
        invalid_type            = 4
        no_authority            = 5
        unknown_error           = 6
        header_not_allowed      = 7
        separator_not_allowed   = 8
        filesize_not_allowed    = 9
        header_too_long         = 10
        dp_error_create         = 11
        dp_error_send           = 12
        dp_error_write          = 13
        unknown_dp_error        = 14
        access_denied           = 15
        dp_out_of_memory        = 16
        disk_full               = 17
        dp_timeout              = 18
        file_not_found          = 19
        dataprovider_exception  = 20
        control_flush_error     = 21
        OTHERS                  = 24.
    * old functioanlity
    *    CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY'
    *      EXPORTING
    *        i_file_front_end       = lv_file_name
    *        i_file_appl            = lv_file_appl
    *        i_file_overwrite       = 'X'
    ** IMPORTING
    **    E_FLG_OPEN_ERROR          =  false
    **    E_OS_MESSAGE              =  lv_message
    *    EXCEPTIONS
    *      fe_file_open_error       = 1
    *      fe_file_exists           = 2
    *      fe_file_write_error      = 3
    *      ap_no_authority          = 4
    *      ap_file_open_error       = 5
    *      ap_file_empty            = 6
    *      OTHERS                   = 7
    This is for the download, similarly should be done for the upload.
    Hope this could help. Let me know if further details are needed.
    Thank you and bye,
    Flavio

  • Download files from a SharePoint library based on conditions

    Hello,
    I'm currently using a PowerShell script to download all the files from a SharePoint document library. The script works like a charm! I am now adding a new column to this document library which has the Yes/No choice and Yes is the default. I want the script
    to only download the items whose choice is Yes and then change the choice to No. Any advice?
    Below is the script I am currently using.
    ######################## Start Variables ########################
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 
    $destination = "C:\Temp\scripts\msg"
    $webUrl = "http://sp13test.sharepoint.com/"
    $listUrl = "http://sp13test.sharepoint.com/Docs/"
    $web = Get-SPWeb -Identity $webUrl
    $list = $web.GetList($listUrl)
    function ProcessFolder {
        param($folderUrl)
        $folder = $web.GetFolder($folderUrl)
    foreach ($file in $folder.Files) {
            #Ensure destination directory
    #        $destinationfolder = $destination + "/" + $folder.Url 
            $destinationfolder = $destination
            if (!(Test-Path -path $destinationfolder))
                $dest = New-Item $destinationfolder -type directory
            #Download file
            $binary = $file.OpenBinary()
            $stream = New-Object System.IO.FileStream($destinationfolder + "/" + $file.Name), Create
            $writer = New-Object System.IO.BinaryWriter($stream)
            $writer.write($binary)
            $writer.Close()
    #Download root files
    ProcessFolder($list.RootFolder.Url)
    #Download files in folders
    foreach ($folder in $list.Folders) {
        ProcessFolder($folder.Url)

    Hi NSUT,
    Thank you for the script and it almost works 100%. I currently have 7 documents of which only 6 download. The 'Downloaded' column of all 6 changes to 'Yes'. For some reason one column will not update and its document will not download. I am also get he below
    error.
    Here's my script
    ######################## Start Variables ########################
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    $destination = "D:\Temp\Scripts\msg"
    $webUrl = "http://sp13test.sharepoint.com/"$listUrl =
    http://sp13test.sharepoint.com/Docs/
    $web = Get-SPWeb -Identity $webUrl
    $list = $web.GetList($listUrl)
    #Write-host $list
    function ProcessFolder {
        param($folderUrl)
        $folder = $web.GetFolder($folderUrl)
      foreach ($file in $folder.Files) {
     $item = $file.Item
            #Ensure destination directory
            $destinationfolder = $destination
            if (!(Test-Path -path $destinationfolder))
                $dest = New-Item $destinationfolder -type directory
     if ($item["Downloaded"] -eq "No") {
            #Download file
            $binary = $file.OpenBinary()
            $stream = New-Object System.IO.FileStream($destinationfolder + "/" + $file.Name), Create
            $writer = New-Object System.IO.BinaryWriter($stream)
            $writer.write($binary)
            $writer.Close()
     $item["Downloaded"] = "Yes"
     $item.Update();
    #Download root files
    ProcessFolder($list.RootFolder.Url)
    #Download files in folders
    foreach ($folder in $list.Folders) {
        ProcessFolder($folder.Url)

  • Open and print multiple files from the Finder all at once.

    I'm trying to research how to do this. In OS9 you used to be able to hi-lite multiple files (Word files for example) and just hit Command+P. This would automatically open all of the files AND print them.
    I can't seem to do this in my OS X. Or can I? I can hi-lite and go to File/Print, but the computer is only opening but not printing.
    Any suggestions??
    iMac   Mac OS X (10.4.8)  

    I don't know how to both "open and print" multiple files in one step. The ⌘O combination of course will open multiple items. The items remain selected so switching back to the "Finder" and dragging multiple icons onto the icon for "/Applications" > "Utilities" > "Printer Setup Utility.app" seems to cause them all to be printed to the default printer.
    Alternatively, a user's "~/Library/Printers" folder contains printer icons -- I'm not sure what they are exactly, but they represent the printers set up for that account. They function pretty much like the pre-OS X "Desktop Printer" icons so dragging and dropping multiple files onto them should cause them to be printed. It may even be possible to create aliases to them on the "Desktop" to recreate "Desktop Printer" functionality. But again, this won't open the files into their applications.

  • Download and upload Z programs from one r/3 to another r/3 system

    hi,
    i want to download all Z programs( reports, screens, function modules etc) from one R/3 system and upload the same into another R/3 system.
    can anyone give me the sample code for this please
    thanks.

    hi Radhika,
      For that save those programs into some transport request by assigning the development class and release the request to the system where you want the program to be ..
    for assigning those programs on to some development class follow this path SE38 give the program name ... GOTO->OBJECT DIRECTORY ENTRY-> give the development class by changing $tmp to some development class
    Regards,
    santosh

  • Help~how can I download and upload pdf file in simple solution

    I am new doing Portal.
    I want to create a page which can provide download pdf file function and other page which can provide upload pfg file function.
    I created a link to download file, and implemented uploading files by access the file directory.
    Can this solution work in Portal?
    I've tried, but I couldn't access file directory through web_dav.
    Anyone can give me some suggestion?

    You can only install apps (programs) via the App Store app on your iPad, or by downloading them via iTunes store on your computer and then syncing them to your  iPad - you can't download and install programs from the internet via a browser, they are not compatible with the iPad.

  • How to download and upload a document from/to UCM?

    Hi Folks,
    I am trying to find any information related to UCM regarding how to upload a file to UCM and how to download a file from UCM through WebCenter11g.  Any suggestions will be appreciated.
    thanks
    new to ADF

    I Hope you want to upload documents via your ADF Application??
    If yes , then use RIDC
    PFB a useful link
    Andrejus Baranovskis's Blog: Oracle UCM 11g Remote Intradoc Client (RIDC) Integration with Oracle ADF 11g

  • Using AMP to download and save FLV files from web sites?

    I thought I had heard months ago that this new media player was going to allow you to download and save the FLV files from web sites like YouTube and others, where a direct download while possible, isn't the easiest thing to currently do. But I don't really see any way in this new media player to download and save files from web sites....it's plenty willing to play them if they're already saved on your hard drive, but I thought one of the reasons for Adobe building this was to make it easier to get them in the first place?

    I'd have to agree. This is one of the most useless products I have seen from a company of this standard. Why they continue to provide this product as an example of what can be done with AIR, is bewildering.  Myself and others have posted over and over again that the player deletes the saved movies at some random time, an hour or two hours after they appear to be saved.
    What is the point of having a 'saved' icon the CD ICON if that movie will be deleted   FOR NO BLOODY reason.  I just wasted 400 mb of my quota dowloading moves 3 times...!! just to realise that the application deletes them from the VERY CACHE that it copies them to.
    Adobe, if this is what I can expect while trying to view the tutorials for FLEX what will the development experience be like. Myself and others are fed up with posting this bug to Adobe, just to be ignored. How much stress to do you want on your servers before you WAKE UP.
    I have been in 4 meetings over the last 2 weeks and everyone has remarked about the 'experience' trying to view these tutorials.
    Wake up to yourself. If you want to charge $500 for FLEX then atleast fix this crappy player.
    PS. I note that this player is supposedly built with Flex and that the list control truncates rather than wraps, in addition, no 'tool tips',  dates are not localised, the video keeps unpausing itself each time I return from the downloads page, no settings for where files should be cached. Occasionally the underlining (grey) window bar appears over the top of the flash window edge.  I've used the application for an hour or so...
    Where is the alternative... I'll be glad when Adobe get some real competition.. so that they pay attention to input.  A big wastefull site if all support does is read and ignore posts.!!!!!!!!!!!!

  • BT Cloud - how to upload multiple files from my an...

    As the title says, how do you do this.? I can only see how to upload single photos at a t ime.
    thanks
    David

    If you use the web interface you can drag-drop up to 200 files at a time.
    If you use the code installed on a PC/Mac, you can add a folder using 'add to backup', and all files and subfolders will get automatically uploaded (and thed folder structure will stay intact).  To install, log in to MyBT, choose the My BT Could button, and the next page will have a download button.
    Any future changes to files in that folder and subfolder will also get backed up: insertions, changes and deletions.  It isn't a real backup: beware with the automatic client version that when you delete files from the folder, they will be deleted from the Cloud backup.
    ~~~
    If you are mainly using it for photos, you may find the not very advertised free Flickr Pro account you can get by signing up with your BT email is more suitable.  Though I still haven't found a really convenient mass upload mechanism for Flickr either.

  • Uploading Multiple Files from web client to web server

    Am using a Digitally signed applet to pickup files from a specific directory and only to pickup those of a specific type. Applet is called by a HTML converted page and uses the JAVA 1.3.1 plug-in. Client side is ok, but the server side does not work - cannot see how to drop the files down onto the web server.
    code
    URL url = null ;
    FileInputStream filReader = null ;
    DataOutputStream dosOutfile = null ;
    HttpURLConnection httpUrlConn = null ;
    int bytes = 0 ;
    //read local file on client's hd with signed applet
    try
    filReader = new FileInputStream( new File( fromFile ) );
    catch ( java.io.FileNotFoundException eNotFound )
    DisplayStatus ( fromFile + " Not found");
    eNotFound.printStackTrace();
    // start setup to server-side copy of in file
    try
    url = new URL ( toFile ) ;
    catch ( java.net.MalformedURLException eMalFormedUrl )
    DisplayStatus ( url + " url mal formed");
    eMalFormedUrl.printStackTrace();
    // create a HttpUrl connection for POSTING
    try
    httpUrlConn = (HttpURLConnection) url.openConnection(); // do not remove this casting, as needed
    catch ( java.io.IOException eIoException )
    DisplayStatus ( url + " IO not possible");
    eIoException.printStackTrace();
    // set preferences
    httpUrlConn.setDoInput(true); // default value, but best make sure
    httpUrlConn.setDoOutput(true); // default value, but best make sure
    httpUrlConn.setUseCaches(false); // enable write straight through
    try
    httpUrlConn.setRequestMethod("POST") ;
    // httpUrlConn.setRequestMethod("PUT") ;
    } catch ( java.net.ProtocolException eProtEx )
    DisplayStatus ( "Protocol Exception on setting up POST") ;
    eProtEx.printStackTrace();
    httpUrlConn.setRequestProperty("Content-Type", "multipart/form-data");
    // permissions?
    try
    java.security.Permission permission = httpUrlConn.getPermission() ;
    if ( iDebug == true )
    DisplayStatus ("Permission = " + permission.toString() ) ;
    DisplayStatus ( "Actions = " + permission.getActions() ) ;
    DisplayStatus ( "Name = " + permission.getName() ) ;
    catch ( java.io.IOException eUrlIOConnException )
    DisplayStatus ( "httpUrl " + httpUrlConn + " IO not possible");
    DisplayStatus ( eUrlIOConnException.toString() ) ;
    eUrlIOConnException.printStackTrace();
    // connect
    try
    this.VerifyHttpResponseCode ( httpUrlConn.getResponseCode() ) ;
    DisplayStatus ("About to connect") ;
    httpUrlConn.connect() ;
    DisplayStatus ("Connected") ;
    if ( iDebug == true )
    DisplayStatus ("Connected Content Encoding = " + httpUrlConn.getContentEncoding() ) ;
    DisplayStatus ("Connected Content Length = " + httpUrlConn.getContentLength() ) ;
    DisplayStatus ("Connected Content Type = " + httpUrlConn.getContentType() ) ;
    DisplayStatus ("Connected default allow user interaction = " + httpUrlConn.getDefaultAllowUserInteraction() ) ;
    DisplayStatus ("Connected File Map = " + httpUrlConn.getFileNameMap() ) ;
    DisplayStatus ("Connected request method = " + httpUrlConn.getRequestMethod() ) ;
    DisplayStatus ("Connected response code = " + httpUrlConn.getResponseCode() ) ;
    DisplayStatus ("Connected response message = " + httpUrlConn.getResponseMessage() ) ;
    DisplayStatus ("Connected = " + httpUrlConn.getURL() ) ;
    } // end of debug print out status
    catch ( java.net.ConnectException eConnEx )
    this.DisplayStatus ( "Connection error - no server listening or incorrect port " ) ;
    this.DisplayStatus ( "Connection error - http = " + httpUrlConn) ;
    eConnEx.printStackTrace();
    catch ( java.io.IOException eUrlConnException )
    DisplayStatus ( "url " + url + " connection not possible");
    DisplayStatus ( eUrlConnException.toString() ) ;
    eUrlConnException.printStackTrace();
    // create file on server
    try
    dosOutfile = new DataOutputStream ( new BufferedOutputStream( httpUrlConn.getOutputStream () ) ) ;
    catch ( java.io.IOException eNewFileIO )
    DisplayStatus ("Unable to create file on server / buffer output stream " + toFile ) ;
    // copy files char by char for the moment, till testing complete
    try
    bytes = filReader.read();
    while(bytes != -1)
    dosOutfile.writeByte(bytes);
    bytes = filReader.read();
    // close both files
    dosOutfile.flush ();
    dosOutfile.close ();
    filReader.close();
    catch (java.io.IOException eCpyIo )
    DisplayStatus ("Error copying files") ;
    connection of the HttpURLConnection
    gives 'Fobbiden' response for 'PUT'
    and
    'method not allowed' for 'POST'
    trying to create the file on the server than causes IOException at the create DataStream line
    What am I doing wrong?
    Is this philosphy correct?
    Should the HttpURLConnection be to the target folder
    and then create the file in it?

    hello,
    first here is my interpretation of your prob.
    You have a client.From this client you are trying to upload files onto a server.
    Finding the files and reading them on the client side is not a prob. The prob is storing them on the server side.
    right?
    If the above stated prob is right, here is a solution.
    1. You have to first inform the server that you are sending the file. Unless you do so the server will not understand when you have started sending the file.
    So, initially, the applet which you have written need to communicate with a servlet on the server side.
    This can be done using reqs.. .get or post.In the req itself you can even send the name of the folder wherein you want to store the file you are going to transfer later on.
    Next, after receiving the folder name, the servlet can now understand that next file data is going to be received.
    The applet now sends the file which is received by the servlet and stored appropriately.
    You need to explicitly write a servlet to receive a data into the file and then store the file into appropriate folder.
    for any further probs email me at [email protected]

  • How to Upload Multiple Files from a folder at a single go?

    Hi friends,
    My requriment is to Upload many txt or excel files in a single shot.
    If its a single file i can upload through Ws_upload or Gui_upload.
    in the same way is there any function modules to upload many files at a time.
    Regards
    Venkatesh.S

    Hi Venkatesh,
    Try this code..
    data: l_filename type string OCCURS 0 WITH HEADER LINE.
    l_filename = 'c:\temp1.xls'.
    APPEND L_FILENAME
    l_filename = 'c:\temp2.xls'.
    APPEND L_FILENAME
    LOOP AT L_FILENAME
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    FILENAME = l_filename
    FILETYPE = 'ASC'
    HAS_FIELD_SEPARATOR = '#'
    TABLES
    DATA_TAB = itab1.
    OPEN DATASET <applicationfilename> FOR OUTPUT IN TEXT MODE.
    IF sy-subrc = 0.
    LOOP AT ITAB1
    TRANSFER ITAB1 TO pt_infil .
    ENDLOOP.
    ENDIF.
    CLOSE DATASET pt_infil.
    ENDLOOP.
    OR
    use CL_GUI_FRONTEND_SERVICES->DIRECTORY_LIST_FILES
    Regards,
    Goutham.

  • Can't select and print multiple files from Mac OS' Finder

    I'm using Acrobat Reader on Mac OSX. I'm used to be able to select multiple files in Finder and then press Apple-P to print all of them in one batch. Reader blocks this, by opening the first of the documents and then display the Print Setup dialogue, instead of just printing the document according to the default settings.
    When the dialogue is displayed, the reader is blocked from opening and printing the remaining documents, and just displays an error message that it couldn't open them. That is not a nice behaviour.

    Hi Mikael,
    It is not possible to open another document while printing another document through Acrobat.
    You might want to create an action in Acrobat to print all the pdf's in a particular folder.
    Regards,
    Rave

  • Download and extract jar file from applet

    Can any one provide me a solution for my below problem. Thanks in advance for all the suggestions.
    I want my applet to download a jar file, extract into users home directory by creating a folder and then set the created folder to java library path.
    My applet html file is in "root" directory. The applet is included into applet.jar and placed under "lib" directory which is under "root" directory.
    Now i also had another jar file(contains dlls what I packed) under the same lib folder.
    The below is the following directory structure in my server.
    root ---
         |
         |
         default.html
         lib--
         |
         |
         applet.jar - contains applet related classes
         native.jar - contains dlls which are to be loaded
    When a client downloads my applet, it should copy the native.jar and then extract into a new folder under user home directory. Then set this folder to java library path.
    Regards
    raman kumar

    I managed to do it this way, Just remember that you need to sign the jar files for your applet, else it won't work.
    package jar.extract;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.jar.JarFile;
    import java.util.zip.ZipEntry;
    public class JarExtractor {
         // Dll file in the jar
         private static String JAR_FILE = "dll.jar";
         public void extract() {
              try {
                   JarFile jf = new JarFile(JAR_FILE);
                   // Entry in the jar file rember package and dll file
                   ZipEntry ze = new ZipEntry("package/dll_file");      
                   int length = (int) ze.getSize();
                   byte fileContent[] = new byte[length];
                   InputStream fin = jf.getInputStream(ze);
                   fin.read(fileContent, 0, length);
                   // CODE missing.
                   // You need to write the input stream (fin) to a new files output stream
                   // it is like copying a file !!!
              } catch (IOException e) {
                   e.printStackTrace();
    }Tom

  • Download and Upload Modulepool program

    hai all,
       Could any one say how to Download and Upload Modulepool program from sap.
    Thanks,
    Jeevan.

    Hi Puduru
    Welcome to ABAP forums.
    If you just want to export Module pool program once, you can use transaction SE80 and menu point Utilities->More Utilities->Upload/Download->Download option ( for each include / component ).
    Save it as a text file and then repeat the same process.
    Here's other programs for the same functionality. You can use one of them.
    http://www.members.tripod.com/abap4/Upload_and_Download_ABAP_Source_Code.html
    http://sap.ittoolbox.com/code/d.asp?d=1623&a=s
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/finding your code in bsp applications.article
    http://www.geocities.com/rmtiwari/Resources/Utilities/WebViewer.html
    http://www.dalestech.com/
    Dont forget to rewards pts, if it helps ;>)
    Regards,
    Rakesh

Maybe you are looking for

  • Bapi To create sales order with reference of sales order.

    Hi all,       Having requerment To create sales order with reference of onother  open sales order. Example: there open sales order which having qty of 20 for that 10 qty as already billed , for remain  10 qty as to create the new sales order with ref

  • Old Mac games not working

    I've just found a box with some of my favourite old Mac games in that I used with my old Lime iMac. Titles such as FA/18 Hornet, Command and Conquer and Railroad Tycoon amongst others. I also have some education disks that are invaluable resources. I

  • How to calculate moving average price?

    hi, i need someone to explain to me how to calculate moving average price

  • Another ringtone query !!

    I have converted one of my itunes to a ringtone ...m4r etc I need to drag it into the ringtones folder in my i tunes library so that it will sync with my i phone BUT I have no ringtones folder in my i tunes library. can anyone tell me how I create on

  • I cannot get into any sights

    When I click on Firefox, I enter the then type in a site or subject, and every time the response is "Unable to connect" box. This situation began 17.08.2010.