Upload file to nested file in SharePoint 2013 document library

Hi,
I want to retrieve foders & subfolder from document library and bind it with a dropdownlist.I am able to bind all folder & subfolderto the dropdownlist as below image.
Now I want upload a file to folder selected in the drop down list.By using the below code I am able to add files in the root folder,but while submitting the file to sub folder it showing "Value does not fall in this range"
 if (item.Title == ddlFolderName.SelectedValue)
                                                if (item != null)
                                                   SPFolder selfold = lifolder.RootFolder.SubFolders[ddlFolderName.SelectedValue];
                                               SPFile fFile = selfold.Files.Add(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName),
byt);
                                                    fFile.Item.Update();
                                                    fFile.Update();
                                                    lblMsg.Text = "File added";
}}Please help.Thank you

Hi Aditi,
For uploading a file into a nested folder you could consider the following approach:
ensure the target folder exist using the method provided below
upload a file using
SPFileCollection.Add method
How to ensure a nested Folder exist using SharePoint SSOM
internal static class SPFolderExtensions
/// <summary>
/// Ensure SPFolder
/// </summary>
/// <param name="web"></param>
/// <param name="listTitle"></param>
/// <param name="folderUrl"></param>
/// <returns></returns>
public static SPFolder EnsureFolder(this SPWeb web, string listTitle, string folderUrl)
if (string.IsNullOrEmpty(folderUrl))
throw new ArgumentNullException("folderUrl");
var list = web.Lists.TryGetList(listTitle);
return CreateFolderInternal(list, list.RootFolder, folderUrl);
private static SPFolder CreateFolderInternal(SPList list, SPFolder parentFolder, string folderUrl)
var folderNames = folderUrl.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
var folderName = folderNames[0];
var curFolder =
parentFolder.SubFolders.Cast<SPFolder>().FirstOrDefault( f => System.String.Compare(f.Name, folderName, System.StringComparison.OrdinalIgnoreCase) == 0);
if (curFolder == null)
var folderItem = list.Items.Add(parentFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder,
folderName);
folderItem.SystemUpdate();
curFolder = folderItem.Folder;
if (folderNames.Length > 1)
var subFolderUrl = string.Join("/", folderNames, 1, folderNames.Length - 1);
return CreateFolderInternal(list, curFolder, subFolderUrl);
return curFolder;
How to create nested Folder using SharePoint SSOM
internal static class SPFolderExtensions
/// <summary>
/// Ensure SPFolder
/// </summary>
/// <param name="web"></param>
/// <param name="listTitle"></param>
/// <param name="folderUrl"></param>
/// <returns></returns>
public static SPFolder CreateFolder(this SPWeb web, string listTitle, string folderUrl)
if (string.IsNullOrEmpty(folderUrl))
throw new ArgumentNullException("folderUrl");
var list = web.Lists.TryGetList(listTitle);
return CreateFolderInternal(list, list.RootFolder, folderUrl);
private static SPFolder CreateFolderInternal(SPList list, SPFolder parentFolder, string folderUrl)
var folderNames = folderUrl.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
var folderName = folderNames[0];
var curFolder =
parentFolder.SubFolders.Cast<SPFolder>()
.FirstOrDefault(
f =>
System.String.Compare(f.Name, folderName, System.StringComparison.OrdinalIgnoreCase) ==
0);
if (curFolder == null)
var folderItem = list.Items.Add(parentFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder,
folderName);
folderItem.SystemUpdate();
curFolder = folderItem.Folder;
if (folderNames.Length > 1)
var subFolderUrl = string.Join("/", folderNames, 1, folderNames.Length - 1);
return CreateFolderInternal(list, curFolder, subFolderUrl);
return curFolder;
Key points:
Ability to create a nested folder(s)
Existing folders will not be affected
The following example demonstrates how to ensure the following folder structure exist under
Documents library and upload a file into it:
Orders
|
A --
|
A1
Example:
var folder = web.CreateFolder("Documents", "Orders3/Orders A/Orders A1");
Example: how to upload a file into a nested folder
var targetFolder = web.EnsureFolder("Documents", "Orders3/A/A1");
var fileContent = System.IO.File.ReadAllBytes(fileName);
var fileUrl = Path.GetFileName(fileName);
targetFolder.Files.Add(fileUrl, fileContent);
Thanks & Regards
Indul Hassan
www.indulhassan.com

Similar Messages

  • Can't open MS Word .doc files from SharePoint 2013 document library?

    Hello,
    I have uploaded some MS Word files with .doc extension into a SharePoint 2013 document library, but they don't open when clicked.  I can do a number of things to the file, like view and edit properties, download and other things, but it does not
    open up when mouse clicked.  There are PDF files in the document library and they open up just fine.  Any ideas?
    I should add that MS Word 2010 .docx files can not be opened either.
    Thanks.
    Paul

    Hi,
    Whether you use office 2013.
    Considering this .doc file can be smoothly opened in Office if you downloaded it to your local, it indicates that the Word document and Microsoft Word doesn’t have any problems. The issue may be caused by the compatibility between Office
    and your site.
    1.Check whether you have the SharePoint OpenDocuments Class add on enabled at first.
    Internet Explorer >Tools iron > Manage add-ons >
    Choose to Show All add-ons. Find SharePoint OpenDocuments Class and make sure it’s enabled.
    2.go to Compatibility view settings > add your SharePoint site to compatibility view
    3.go to Internet Options,
    Advanced > Reset… > Check Delete personal settings and reset
    Security > Trusted sites > sites > add SharePoint sites to trusted sites
    4.If it doesn’t work, please open Word, go to Options > Trust Center > Trust Center Settings > Protected View > Uncheck all.
    Best Regards,
    Lisa Chen
    Lisa Chen
    TechNet Community Support

  • 2GB of video file upload to SharePoint 2013 document library

    Hi All,
    We have a requirement of uploading a 2GB of video file to a SharePoint 2013 document library. Will there be any issue due to increasing the maximum file size?
    Many Thanks,
    sudesh withanage

    It will be better if you save all your videos at one location,i.e Asset Library.Check the link for Asset libraries
    http://technet.microsoft.com/en-us/library/ee414275(v=office.15).aspx
    In case you want to add other files (i,e excel ,word) along with videos you will need to increase library size,
    Check the following link to increase the file size ,as well as the issues and workaround to solve the problems
    http://blogs.technet.com/b/praveenh/archive/2012/11/16/issues-with-uploading-large-documents-on-document-library-wss-3-0-amp-moss-2007.aspx
    Please Mark it as answer if this reply helps you in resolving the issue,It will help other users facing similar problem

  • Email attachments from SSRS email subscription are not being uploaded to an email enabled SharePoint 2013 document library

    Email attachments from SSRS email subscription are not being uploaded to an email enabled SharePoint 2013 document library.
    I have tested the library using a standard email (with attachment) to the library and this works fine. 
    I have monitored the drop folder on the server and I can see both emails being picked up in drop and processed by SharePoint.  The email sent from a regular email account is uploaded with the attachment, whereas the email sent via SSRS subscription
    email is uploaded and the attachment (report) is missing.

    An update on this.  The email when sending from SSRS subscription is received in the library and the attachment is contained within the .EML file uploaded.
    The behaviour that I would like from SSRS subscription emails are to just have the document and not the email.
    Below is a snippet of the .EML files I quick copied from the Drop folder.
    Email attachment snippet sent from SSRS Subscrption:
    ----boundary_2477_75fa3d73-56de-4948-ad82-6588f3a35b95
    Content-Type: application/octet-stream; name="Toilet Usage by Month.docx"
    Content-Transfer-Encoding: base64
    Content-Dis;
     filename="=?utf-8?B?VG9pbGV0IFVzYWdlIGJ5IE1vbnRoLmRvY3g=?="
    Content-ID: <10722c0f-749e-4ecb-ac3f-206317bae734>
    UEsDBBQAAAAIAEVcbEY4Xh4a5nsAAPJtMQARABwAd29yZC9kb2N1bWVudC54bWwgohgA
    KKAUAAAAAAAAAAAAAAAAAAAAAAAAAAAA7N1rr1/XcSforyL4VRooR3vd9to76Kihjto9
    I8T2TDvAzFuaPrE1kUiCouxWPv38DyX50nHSniCdyS96bIAUL+d/LnxO7Vq11qr6j//p
    v3/x+Qe/fnr75WevX/3lD9qfHz/44OnVy9e/+OzVL//yB1+9+9sfXj/44Mt3L1794sXn
    r189/eUPvn768gcf/KeP/uNv/uIXr19+9cXTq3cfPF7h1Zd/8evHH/7q3bs3f/Hhh1++
    /NXTFy++/PPXb55ePf7wb1+//eLFu8cv3/7ywy9evP27r9788OXrL968ePfZzz/7/LN3
    X3/Yj+P8wbcv8/rxXt+++otvX+KHX3z28u3rL1//7bvnN/mL13/7t5+9fPr2p+/e4os/
    5f1+8yaffPshv3+Pj4/l3a++e5Ff/1Pv9tdffP7d3/vNmz/lvf3i7YvfPL6AX3z+zTv6
    Email attachment snippet sent from Outlook:
    --_004_A4C6DCEDE4346446A79AFF493D278530FB87FA07MELABCDEXA1airp_
    Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document;
     name="Toilet Usage by Month.docx"
    Content-Description: Toilet Usage by Month.docx
    Content-Dis; filename="Toilet Usage by Month.docx";
     size=76574; creation-date="Thu, 12 Mar 2015 00:41:14 GMT";
     modification-date="Thu, 12 Mar 2015 00:41:14 GMT"
    Content-Transfer-Encoding: base64
    UEsDBBQAAAAIAMJcbEY4Xh4a5nsAAPJtMQARABwAd29yZC9kb2N1bWVudC54bWwgohgAKKAUAAAA
    AAAAAAAAAAAAAAAAAAAAAAAA7N1rr1/XcSforyL4VRooR3vd9to76Kihjto9I8T2TDvAzFuaPrE1
    kUiCouxWPv38DyX50nHSniCdyS96bIAUL+d/LnxO7Vq11qr6j//pv3/x+Qe/fnr75WevX/3lD9qf
    Hz/44OnVy9e/+OzVL//yB1+9+9sfXj/44Mt3L1794sXnr189/eUPvn768gcf/KeP/uNv/uIXr19+
    9cXTq3cfPF7h1Zd/8evHH/7q3bs3f/Hhh1++/NXTFy++/PPXb55ePf7wb1+//eLFu8cv3/7ywy9e
    vP27r9788OXrL968ePfZzz/7/LN3X3/Yj+P8wbcv8/rxXt+++otvX+KHX3z28u3rL1//7bvnN/mL

  • SharePoint 2013 document library, permissions to upload and view shared document only

    SharePoint 2013 document library I want to give access to client where they can upload and view their uploaded document and can see all documents shared with them.
    I have managed to show all document shared with them only by deactivating a feature but now they can't upload any document, If I create a permission set to allow them to upload documents, they will see all other documents as well which are not shared with them.
    Any suggestions?

    Hi Sharaqat, the best way to handle your situation is to have a separate library or site for the client. You could use item level permissions per Thilosh, but fine-grained permissions become a major headache. You could also use web parts and audience
    targeting, but that's not truly secure.
    cameron rautmann
    I am thinking to have a separate document library for client, where they can upload/view/edit etc, we will upload documents in a "secure" library with a column saying this is a private document or public document, if we mark a document public,
    a workflow will move that document to the client's document library. I don't think there would be a problem to move a document from 1 library to another in a workflow.
    That's the easiest solution I have found so far.

  • Connecting a SharePoint 2013 Document Library to Outlook 2010 client

    Good Day,
    Can someone please confirm if you can connect a SharePoint 2013 Document Library to Outlook 2010 client?
    I have seen articles, like the one shown below for Outlook 2013 to SharePoint 2013;
    http://www.sharepointgeoff.com/how-to-connect-a-sharepoint-2013-document-library-to-outlook-2013/
    Please provide a link to documentation to validate what Outlook Office versions will support viewing Document Library from Outlook client from a SharePoint 2013 Document Library.
    Thanks in advance for taking the time to review my request.
    Regards,
    Mark

    Hi Mark,
    Per my understanding, you might want to connect SharePoint 2013 Document Library to Outlook 2010 client application.
    Yes, SharePoint 2013 Document Library can connect to Outlook 2010 client application, the connecting process is similar as what SharePoint 2013 connect to Outlook
    2013 client application does.
    Thanks
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • SharePoint 2013 document library workflow to send emails when document changes

    Hi All,
    Need a email alerts to setup when documents get change in a SharePoint 2013 document library.  Mail should go to all the members in a SharePoint Security group.
    Many Thanks 
    sudesh withanage

    Out of the box , You cannot set alerts for SharePoint group. You may try -
    1- Create a group in active directory, add users to the ADgroup. Add that ADgroup in Sharepoint and configure alert.
    2- You can set up a new user and change their email to that of a distribution list, and then assign the alerts to this user.
    3- You can create a custom workflow/action or event receiver that will send an email to a distibution list or programmatically traverse the SPGroup's members and send them the notification email, whenever an item is added or changed.
    4- You can try this , this was for WSS3 -
    http://advancedalert.codeplex.com/
    5- you can to use SharePoint Designer and create a workflow that send an email to SharePoint group.
    Thanks
    Ganesh Jat [My Blog |
    LinkedIn | Twitter ]
    Please click 'Mark As Answer' if a post solves your problem or 'Vote As Helpful' if it was useful.

  • Cannot able to save Excel 2013 file in Sharepoint 2007 document library

    Dear All,
    We have SharePoint 2007 intranet portal where in we have teamplace created for internal users to collaborate on documents.
    Now we are having issues when using uploads Excel 2013 or Excel 2010 file on document library and try to edit the document.
    Sometimes it doesn't allow to check out the file it say someone already checked out ..but when I try in my laptop its OK.
    And some times when user opens the file it opens as non editable file and it does not take any changes.
    Pls advise whether there is issue with SharePoint 2007 document library and Office Excel 2010,2013 files.
    -- Regards Sandeep

    The lock can apply in two places.  Are you seeing the message in your browser or does it arise within Excel itself?
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

  • Uploading XML file to SharePoint Online Document Library

    Hi,
    I got a scenario to upload the xml file the sharepoint library along with that the XML has some information like UserName, Email. Phone and these information has to be captured to the metadata information of that file in the sharepoint library.
    Let me know if you have a solution for this.
    Thanks
    Karthik

    Hi Karthik,
    Per my understanding, there is an XML file contains attributes. You want to upload it to a SharePoint library as well as extract the values of those attributes to
    save to the corresponding columns of the SharePoint library.
    As it is an Online environment, a workaround I would suggest is that you can create a client application(such as Windows Form Application) to extract values from the
    XML file, then upload the file to SharePoint library, submit the values to the same library afterwards. All this can be achieved using SharePoint Client Object Model.
    How to: Complete basic operations using SharePoint 2013 client library code
    http://msdn.microsoft.com/en-us/library/office/fp179912(v=office.15).aspx
    About how to upload file to SharePoint library using Client Object Model:
    http://blogs.msdn.com/b/sridhara/archive/2010/03/12/uploading-files-using-client-object-model-in-sharepoint-2010.aspx
    About how to read XML from a file by using Visual C#:
    https://support.microsoft.com/en-us/kb/307548?wa=wsignin1.0
    Thanks 
    Patrick Liang
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Unable to see existing documents in a Custom Sharepoint 2013 Document library while saving a document directly in it using explorer mode

    Hi,
    We have a SharePoint 2013 doc library based on a custom template, which has been migrated from 2010.
    We are unable to see existing documents in a Document library created using this template while saving a document directly in it using explorer mode, However we can save files and even see them in explorer mode, only when we try to save a new document there
    directly, we cant see the old docs.
    All the OOB libraries work fine.
    Below is the normal behavior while saving a file, however nothing comes up when saving on this custom template library

    Solved it myself guys... (Well the major part)
    Got help from here...
    https://www.nothingbutsharepoint.com/sites/devwiki/articles/pages/blank-open-save-dialog-when-browsing-document-library-from-office-clients.aspx
    and
    http://www.sharepointconfig.com/2011/02/vs2010-list-definition-template-missing-file-dialog-view/
    with some tweaks of my own..
    Still working on it because its showing SharePoint 2010 header... And I need 2013 look...

  • Problem with uploading files to SharePoint 2013 in cloud using web services. Keep getting error message and don't know why.

    Hello everyone. I am having trouble writing a utility that uses SharePoint web services to upload a file and metatag it. It keeps throwing the following error message:
    "The request failed with the error message: -- <html><head><title>Object moved</title></head><body> <h2>Object moved to <a href="/_forms/default.aspx?ReturnUrl=%2fsites%2fgk%2f_vti_bin%2fcopy.asmx">here</a>.</h2>
    </body></html> --."
    Not sure why. I pass the file that I am going to upload to the subroutine and it is suppose to upload it to the appropriate library. I have burned several days on this problem and I am not sure what is going on. I would appreciate anyone that can point me in
    the right direction. Below is the subroutine that I have that is causing the problem. Obviously, I have stripped the name from the example.
    Thanks
    Mike
    ******** <Begin snip of code> **********************
    Public Shared Sub CreateNewDocumentWithCopyService(ByVal fileName As String)
    Dim c As New copyservice.Copy
    c.PreAuthenticate = True
    c.Credentials = New System.Net.NetworkCredential("[email protected]", "mypassword")
    c.Url = "https://x.sharepoint.com/sites/gk/_vti_bin/copy.asmx"
    Dim myBinary As Byte() = System.IO.File.ReadAllBytes(fileName)
    Dim destination As String = "https://x.sharepoint.com/sites/gk/Gatekeeper%20Reference/" & System.IO.Path.GetFileName(fileName)
    Dim destinationUrl As String() = {destination}
    Dim info1 As New copyservice.FieldInformation
    info1.DisplayName = "Title"
    info1.InternalName = "Title"
    info1.Type = copyservice.FieldType.Text
    info1.Value = "new title"
    Dim info2 As New copyservice.FieldInformation
    info2.DisplayName = "Modified By"
    info2.InternalName = "Editor"
    info2.Type = copyservice.FieldType.User
    info2.Value = "-1;#servername\\testmoss"
    Dim info As copyservice.FieldInformation() = {info1, info2}
    Dim resultTest As New copyservice.CopyResult
    Dim result As copyservice.CopyResult() = {resultTest}
    Try
    ' When creating new content use the same URL in the SourceURI as in the Destination URL argument
    c.CopyIntoItems(destination, destinationUrl, info, myBinary, result)
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try
    End Sub
    ******** <End snip of code> **********************

    Hi,
    If you want to upload a file to a library in SharePoint 2013 online, I suggest you use Client Object Model or REST API.
    The code snippets in the two threads below will be helpful:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/deac7cb7-c677-47b0-acdc-c56b32dfaac8/uploading-bigger-files-using-csom
    http://stackoverflow.com/questions/17057074/how-to-download-upload-files-from-to-sharepoint-2013-using-csom
    Uploading Files Using the REST API
    http://blogs.msdn.com/b/uksharepoint/archive/2013/04/20/uploading-files-using-the-rest-api-and-client-side-techniques.aspx
    You can handle the authentication with
    SharePointOnlineCredentials object:
    http://www.vrdmn.com/2013/01/authenticating-net-client-object-model.html
    Best regards
    Patrick Liang
    TechNet Community Support

  • Javascript to upload a file to SharePoint 2010 document library

    Please share your ideas. I am using SharePoint 2010. Currently when uploading files to a document library, first the upload form is opening to upload the document and then the edit form. I would like to have both this in the same form. I am trying to
    create a webpart page with the controls to upload the file to document library and assign values to the fields in the library. I am looking for some javascript for doing this. Is there any other way of achieving this? Please share any sample
    code.
    <label for="title">Enter the title for this document:</label> <input type="text" id="title"><br/><br/>
    <input id="inputFile" type="file"/><br/><br/>
    <input id="uploadDocumentButton" onclick="UploadDocument()" type="button" value="Upload Document"/><script type="text/javascript">
            function UploadDocument() {
                //javascript to upload the file to MyLibrary and update the title field
    </script>

    Use the below code step by step :) 
    (1) Html
      <input type="file" id="attafh"  class="AlltextAccount"  />
          <input type="button" value="upload" onclick="rundCode()" />
    (2) JS File 
    function rundCode() {
        var file = document.getElementById('attafh').files[0];
        if (file) {
            UploadMe(file);
    (3) 
    function UploadMe(readFile) {
        var reader = new FileReader();
        reader.readAsArrayBuffer(readFile); //array buffer
        reader.onprogress = updateProgress;
        reader.onload = loaded;
        reader.onerror = errorHandler;
    (4)
    function loaded(evt) {
        var fileString = evt.target.result;
        var X = _arrayBufferToBase64(fileString); // this is the mothod to convert Buffer array to Binary
            var fileInput = document.getElementById('attafh');
            var fileDisplayArea = document.getElementById('fileDisplayArea');
                var file = fileInput.values;
                 var filePath = $('#attafh').val(); // "c:\\test.pdf";
            var file = filePath.match(/\\([^\\]+)$/)[1];
            var soapEnv =
                "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \
                    <soap:Body>\
                        <CopyIntoItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>\
                            <SourceUrl>" + filePath + "</SourceUrl>\
                                <DestinationUrls>\
                                    <string>http://intranet/sites/English/DocumentLibrary/" + file + "</string>\
                                </DestinationUrls>\
                                <Fields>\
                                    <FieldInformation Type='Text' DisplayName='Title' InternalName='Title' Value='Test'  />\
                                      <FieldInformation Type='Text' DisplayName='BudgetId' InternalName='BudgetId' Value='8'  />\
                                </Fields>\
                            <Stream>" + X + "</Stream>\
                        </CopyIntoItems>\
                    </soap:Body>\
                </soap:Envelope>";
            $.ajax({
                url: "http://intranet/_vti_bin/copy.asmx",
                beforeSend: function (xhr) { xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/CopyIntoItems"); },
                type: "POST",
                dataType: "xml",
                data: soapEnv,
                complete: processResult,
                contentType: "text/xml; charset=\"utf-8\""
        SP.SOD.executeOrDelayUntilScriptLoaded(initialize, 'SP.js');
        SP.SOD.executeOrDelayUntilScriptLoaded(test, 'SP.js');
    function errorHandler(evt) {
        if (evt.target.error.name == "NotReadableError") {
            // The file could not be read.
    function _arrayBufferToBase64(buffer) {
        var binary = ''
        var bytes = new Uint8Array(buffer)
        var len = bytes.byteLength;
        for (var i = 0; i < len; i++) {
            binary += String.fromCharCode(bytes[i])
        return window.btoa(binary);
    (5)
    function updateProgress(evt) {
    http://www.abdulazizfarooqi.wordpress.com Abdul Aziz Farooqi [BizTalk & SharePoint Consultant] MCPD Web & MCPD SharePoint 2010

  • Remote upload into sharepoint 2013 document library (cloud based)

    We have a sharepoint 2013 in the cloud.
    Is it possible to have some kind of service (windows or web based) that can access a document library on said cloud server and put files into said document library?
    I don't think we have a lot of behind the scenes access to the cloud instance of 2013.

    Hi,
    As I said above, we could use the Client Object Model to upload the files without the user having to go to SharePoint in the browser first and logging in.
    We can use the credentials in the code as below, the code would copy files to SharePoint online, it worked well in my environment, you can check whether it works.
    public static void CopyDocuments(string srcUrl, string srcLibrary, string destUrl, string destLibrary)
    // set up the src client
    ClientContext srcContext = new ClientContext(srcUrl);
    SecureString passWord1 = new SecureString();
    foreach (char c in "Password01!".ToCharArray()) passWord1.AppendChar(c);
    srcContext.Credentials = new SharePointOnlineCredentials("[email protected]", passWord1);
    Web srcWeb = srcContext.Web;
    List srcList = srcWeb.Lists.GetByTitle(srcLibrary);
    ListItemCollection itemColl = srcList.GetItems(new CamlQuery());
    srcContext.Load(itemColl);
    srcContext.ExecuteQuery();
    // set up the destination context
    ClientContext destContext = new ClientContext(destUrl);
    SecureString passWord = new SecureString();
    foreach (char c in "Password01!".ToCharArray()) passWord.AppendChar(c);
    destContext.Credentials = new SharePointOnlineCredentials("[email protected]", passWord);
    // get the destination list
    Web destWeb = destContext.Web;
    destContext.Load(destWeb);
    destContext.ExecuteQuery();
    foreach (var doc in itemColl)
    try
    //if (doc.FileSystemObjectType == FileSystemObjectType.File) //Field or Property "FileAttachement not found."
    // get the file
    File file = doc.File;
    srcContext.Load(file);
    srcContext.ExecuteQuery();
    // build destination url
    string nLocation = destWeb.ServerRelativeUrl.TrimEnd('/') + "/" + destLibrary.Replace(" ", "") + "/" + file.Name;
    // read the file, copy the content to new file at new location
    FileInformation fileInfo = File.OpenBinaryDirect(srcContext, file.ServerRelativeUrl);
    File.SaveBinaryDirect(destContext, nLocation, fileInfo.Stream, true);
    catch (Exception ex)
    http://blog.blumshapiro.com/blog/2012/08/22/sharepoint-2010-using-the-client-object-model-to-move-files-and-folders-across-site-collections-and-subsites/
    Thanks,
    Jason
    Forum Support Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected].
    Jason Guo
    TechNet Community Support

  • How to create column for attachment in SharePoint 2013 Document Library.

    I've created document Library where user can upload the file while click on Upload option (OOTB).
    Now in this Library I want to create one more column where user can put some comment and attach one more file for reference. 
    For comment I can create "Single line of text" type calumn where user can put some comment but for attachment not sure which type of column I have to create.
    Want to know is there OOTB feature/column available which I can use to Add / create a one more column to upload a document for reference.

    Hi,
    For issue 1, please refer 
    To manage the permissions for a Document Set, you must have at least the Design or Full Control permission level.
    On the Welcome Page for the Document Set, click the Manage tab of the Document Set ribbon, and then click Permissions.
    Do one of the following:
    To change the permission settings for the document library itself, click Manage Parent.
    To stop inheriting permissions from the document library and create unique permissions for this Document Set individually, click Stop Inheriting Permissions.
    To view the specific permissions an individual has, click Check Permissions, and then type the name of the user or group you want to check.
    To inherit permissions from the parent document library (if the Document Set was previously configured to stop inheriting them) click Inherit Permissions.
    For more information about working with permissions, see the links under See Also.
    https://support.office.com/en-in/article/Create-and-manage-Document-Sets-c71d5796-d559-48de-b1b3-42383bdd13ea?ui=en-US&rs=en-IN&ad=IN
    For Issue 2:
    You can create a link in the Quick Launch bar
    http://support.sherweb.com/Faqs/Show/how-to-add-a-link-to-the-quick-launch-toolbar-in-sharepoint-sharepoint-2013
    Please don't forget to mark it answered, if your problem resolved or helpful.

  • How to give link to SharePoint 2013 document library column to open its form?

    Hi All,
    I have Infopath document library form, now i want to give link to a specific column to its own item. How to achieve this? Thanks in advance!

    Hi Sam,
    To make the custom field to act as the Name field in the list view, I recommend to use JSLINK to achieve what you want.
    Below is the code example for the js file:
    (function () {
    var overrideCtx = {};
    overrideCtx.Templates = {};
    overrideCtx.Templates.Fields = {
    'Services': { 'View' : CustomLink }
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
    function CustomLink(ctx){
    var link = ctx.CurrentItem["FileLeafRef"];
    var value =ctx.CurrentItem["Services"]
    var html="";
    if(value!="")
    {var html= "<a href='"+link+"'>"+value+"</a>";}
    return html;
    After writing the js file, you need to upload the file to SharePoint and then refer to it in the list view web part.
    http://www.learningsharepoint.com/2012/08/03/sharepoint-2013-using-js-link-to-add-javascript-to-listviewdataview-webpart/
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

Maybe you are looking for

  • How can I connect my iTunes account with PayPal?

    How can I connect my iTunes account with PayPal? In the payment method page (I access it by iTunes for Mac) there's no PayPal button! PS: I live in Italy

  • How NOT to embed attachments?

    I am trying to ATTACH a pdf file to an outgoing email, but no matter what I do it appears inline instead of being a clickable attached file. What's the secret to NOT embedding your attachments within email? I can't find anything under Preferences. TI

  • Real vs reported file size?

    the following procedure is returning the error: ERROR at line 1: ORA-22993: specified input amount is greater than actual source amount ORA-06512: at "SYS.DBMS_LOB", line 639 ORA-06512: at "BANINST1.LOAD_CLOB", line 14 ORA-06512: at line 1 I printed

  • JTextField and TextListener

    I am using an JTextField and I want to be notified when the text there have been changed. But there is no TextListener accessible in JTextField. Do I have to modify a CaretListener ? many Thanks/ Sam

  • Nokia lumia 610 power button problem

    Hi, It has been more than a year since i have been using my nokia lumia 610 but from few days i have been experiencing a problem with my phone . sometimes power button becomes too sensitive and it becomes like a touch button , Also , it turns off by