How to find list or folder name from SharePoint document URL

I'm implementing the SharePoint client object model in my VSTO application in .NET framework 4.0(C#).
Actually we open MS Word files from SharePoint site, we need to create a folder inside the opened documents list/folder and after it we want to upload/add some files to that created folder.
My problem is that how to get list name/title and folder name of opened document by using the documents URL or Is there an another option to find the list or folder name of opened document.
Any help will be appreciable.

In document Library you can get the name of document library directly in URL. for folder name you can try below:
using System;
using Microsoft.SharePoint;
namespace Test
class ConsoleApp
static void Main(string[] args)
using (SPSite site = new SPSite("http://localhost"))
using (SPWeb web = site.OpenWeb())
if (web.DoesUserHavePermissions(SPBasePermissions.BrowseDirectories))
// Get a folder by server-relative URL.
string url = web.ServerRelativeUrl + "/shared documents/test folder";
SPFolder folder = web.GetFolder(url);
try
// Get the folder's Guid.
Guid id = folder.UniqueId;
Console.WriteLine(id);
// Get a folder by Guid.
folder = web.GetFolder(id);
url = folder.ServerRelativeUrl;
Console.WriteLine(url);
catch (System.IO.FileNotFoundException ex)
Console.WriteLine(ex.Message);
Console.ReadLine();
http://msdn.microsoft.com/en-us/library/office/ms461676(v=office.15).aspx
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/801d1a06-0c9b-429b-a848-dd6e24de8bb9/sharepoint-webservice-to-get-the-guid-of-the-folder?forum=sharepointdevelopmentlegacy
You can also try below:
http://blogs.msdn.com/b/crm/archive/2008/03/28/contextual-sharepoint-document-libraries-and-folders-with-microsoft-dynamics-crm.aspx
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d2d5d7cf-9bbd-4e0f-a772-ecdce4e6149f/how-to-fetch-document-guid-from-sharepoint-document-library-using-sharepoint-web-service?forum=sharepointdevelopmentlegacy
http://stackoverflow.com/questions/2107716/how-to-get-guid-of-a-subfolder-in-a-document-library-programmatically

Similar Messages

  • How to get list of file names from a directory?

    How to get list of file names from a directory?
    Please help

    In addition, this:
    String filename = files;Should be this:
    String filename = files;
    That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to find out sub site name from which sub site template is created - in solution gallery

    hi,
     i am having an issue in my "save site as a template". i have created  a subsite few weeks back with doc libs and  splists, disc.forum and  based on the template subsite I have created new subsites. now 
    as  per my new requirement i need to add new  doclibs and few columns in these doc lib. But I am unable to find which sub site was taken as a template.since i have many  subsites with different names, I forgott
    to make meaningful names, i gave some datetime for the templatesubsites,
    like project_27_jul_2pm,project_20_jul_7pm, etc etc.
    So would like to know, is it possible to find out from which subsite I have taken/prepared  the template subsite.
    any APIs are available or any power shell scripts. such that i can find  out from which subsite i have created this  sub site template.

    check this
    http://social.msdn.microsoft.com/Forums/en-US/3c492adb-e7cb-4f5c-8c29-386a21c3498e/how-to-find-out-a-list-of-sites-created-from-a-template?forum=sharepointgeneralprevious

  • How to find the AK Region name from JSP

    I have the requirement to hide some of the fields/regions in Oracle Sales Online.
    To do that from AK Developer Region Name/Code and Region Item is required. How to find this Region Code.

    When you are on the webpage, right click and select "VIEW SOURCE". When the notepad opens up, find the string "TOP REGION". This will give the top region for that page. Query for this page in the AK Developer resp with "Define Regions". Then click on "Region Items". This will give all the Attribute Names and Nested Regions within the TOP REGION. You just have to dig into each one of 'em to find the one you need.

  • How to find a Region id/name from a JTT jsp page

    Hi,
    i am on a SR details page , which i think is , ibuSRDetails.jsp in Isupport. How do i find which region it is belongs to ?
    I wanted to find out the region id /name so that i can customize the region.
    thansk
    -mahendra

    iSupport Documentation
    Or jsp source file. It will have the AK Developer Region Name.
    Or Search AK Developer Attributes with display name of the fields from SR form Header.
    May be iSupport experts might throw some light.
    HTH
    Srini

  • How to find the physical Host Name from a short host name?

    Hi,
      I meet a problem that in RFC destination setting I see some people maintain the
    short name in 'HOST NAME' field. But I need the long phiscial name.
      For example, the short one 'bsw6107', the phisical name is 'bsw6107.wdf.sap.corp'. It there a table or FM to look for it?
      Thank you.
    Regards,
    Yan

    Hi,
    Changing a host name on a central instance is a BIG thing, I personally would rather reinstall instead of changing a hostname...
    What comes immediately to my mind is:
    - SAP profiles
    - .sapenv* .dbenv* scripts
    - OPS$ users
    - /etc/hostname*
    - /etc/hosts
    - TMS (/usr/sap/trans)
    - Backup clients (and backup server changes if you use a central backup system)
    - RFC destination of external systems
    - SAP printers
    - other external systems connecting to the server (Fax, Archiving etc.)
    Regards,
    Sankar

  • How to download list of PO's from Invoice document number.

    Hi,
    We have received a querry from one of the end user regarding Parked Invoice document.User wish to download the list of PO's pertaining to one Parked Invoice document number.
    We can not suggest user to use SE16 due to authorisation issue.
    Please suggest the tcode through which list of PO's can be downloaded for given Invoice document number.
    Regards,
    Kiran

    Hi,
    In T-Code MIR6, give the invoice document number on the initial screen and execute. On the Output screen click on the "Spectacles Icon" and it displays the Invoice document overview. Here the user can see the list of PO for the corresponding Invoice document number.
    If the above does not help, customized report has to be created.
    Thanks and Regards,
    Maheshwari

  • How to keep original Uploaded File Name in SharePoint Document Library?

    HI,
    I have document library. After Uploaded the file in document library. I want to keep the file name in some other filed.
    Why because in future i may change the file name in document library so in order to know the original name of the file.
    I want to do without any workflow. Is there any other default column like that?
    How could i achieve it?
    Thanks & Regards
    Poomani Sankaran

    Hello,
    Here is list of operations for file element, and you can save it in library column:
    http://social.technet.microsoft.com/wiki/contents/articles/22156.sharepoint-2010-a-complete-list-of-spfile-operations-using-ecma-script.aspx
    http://sprider.org/2011/12/13/sharepoint-ecmascript-to-adddeleteupdateget-list-items/
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to find out the file name

    Hi,
    In selection screen (parameter) user will give input TXT file from presentation server to upload to SAP. I need to capture the file name only but not the path and need to concatenate with date stamp and need to download error log in XLS file to presentation server.
    How to find out the file name from selection screen?
    I searched SCN threads but not found relavant solution.
    Thanks,
    R Kumar

    Hi
    This code gets only filename from selection screen :
    REPORT x.
    PARAMETERS p_file(100).
    DATA : gv_full_path LIKE  ibipparms-path,
           gv_full_path_string TYPE string,
           gv_filename(100),
           gv_file_ext(3).
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    Ask user to select file with a popup :
      CALL FUNCTION 'F4_FILENAME'
        IMPORTING
          file_name = gv_full_path.
    Get filename from path :
      gv_full_path_string = gv_full_path.
      CALL FUNCTION 'CH_SPLIT_FILENAME'
        EXPORTING
          complete_filename = gv_full_path_string
        IMPORTING
          extension         = gv_file_ext
          name              = gv_filename.
      CONCATENATE gv_filename '.' gv_file_ext INTO gv_filename.
      p_file = gv_filename.
    I hope it helps.

  • Group by folder name in sharepoint library

    Hi
    Is there any way to group the items based on Folder name in sharepoint Document Library.
    keerthi

    Hi keerthi,
    I agree with pkozan. We can use workflow to exact the folder name from an item, and populate it in a custom column. After than, we can group the items by the custom column.
    In the workflow, we can set the Item's Path value to the custom column.
    But here, I would like to propose another solution. We can use the SharePoint treeview control. With the Treeview control, all folders will be displayed in the tree, then we can display item with a folder by clicking the folder name, without go back to the
    page again.
    For more detailed on this solution, please see:
    http://yetanothersharepointblog.wordpress.com/2012/08/28/adding-a-treeview-to-a-document-library-using-sptreeview-and-sphierarchicaldatasource/
    Thanks,
    Jinchun Chen
    Jinchun Chen(JC)
    TechNet Community Support

  • How can I get a list of database names from environment

    Hi,
    How can I get a list of database names from environment.
    I had found a method in JE API Docs named Environment.getDatabaseNames(), and i couldn't found the same method in Berkeley DB.
    I use java interface, is it supported?
    Thanks.

    Hello,
    I don't know if it would work for you, but have you checked the db_archive utility at:
    http://download.oracle.com/docs/cd/E17076_01/html/api_reference/C/db_archive.html
    Check the -s option.
    Thanks,
    Sandra

  • Event Receiver to get folder Names from List View Web Part

    Hi,
    We have a requirement i.e.
    On one of the page,there are some folders on the list view web part.
    Now through event receiver i should pick the folder names from list view web part and
    update the same in the list.
    If that names already exists in the list then we should leave without updating,if not we have to add folder name in the list.
    Please share your ideas regarding the same.
    Regards,
    Naga Sudheer M
    Thanks & Regards, Sudheer

    Hello,
    LVWP is just for displaying content of site so you need to associate your event receiver with actual list/library. You can create ItemAdded event receiver to check existing folder and create new if not existing. "sk2014" links are good to start.
    http://sharepoint.stackexchange.com/questions/59788/change-name-in-itemadding-event-receiver-or-create-a-new-item
    Let us know in case any doubt
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to find a next bigger no from the list of random numbers

    hi abapers
    can u plz tell me how to find the next bigger no from the given list if some input is given
    the list is 1,2,3,4,8,9
    the input given to the list is 5 and the output should come 8
    i used select endselect but the output is coming 9 i want it 8
    how to do it?

    Try this way
    PARAMETERS : p_num TYPE i.
    TYPES : BEGIN OF ty_itab,
            num TYPE i,
           END OF ty_itab.
    DATA : it_itab TYPE TABLE OF ty_itab,
              wa_itab TYPE ty_itab.
    DATA : a TYPE i.
    wa_itab-num = '1'.
    APPEND wa_itab TO it_itab.
    wa_itab-num = '2'.
    APPEND wa_itab TO it_itab.
    wa_itab-num = '3'.
    APPEND wa_itab TO it_itab.
    wa_itab-num = '4'.
    APPEND wa_itab TO it_itab.
    wa_itab-num = '8'.
    APPEND wa_itab TO it_itab.
    wa_itab-num = '9'.
    APPEND wa_itab TO it_itab.
    SORT it_itab ASCENDING BY num.
    LOOP AT it_itab INTO wa_itab.
      IF wa_itab-num GT p_num.
        a = wa_itab-num.
        EXIT.
      ENDIF.
    ENDLOOP.
    WRITE : / a.

  • Set Folder Name From File Name Inclosed.

    Hello scripters,
    There has been quite a few topics about setting file names from parent folders. I believe it's possible but not sure how to reverse this process. That is to say set the folder name from a file in the folder. This is what I'm imagining.
    I've got a folder. In the folder are 100 folders with the names "untitled folder xxx" In side I've got files that are all named and numbered.
    For example,
    untitled folder/B-day 001~050.jpg
    untitled folder 50/At The Park 001~020.jpg
    I would like a script to change the name of the parent folder of the files that it houses.
    So untitled folder becomes
    B-Day
    untitled folder 50 becomes
    At The Park
    etc…
    I think getting the name of the first file (minus the index number) would be easiest.
    Any help or futher questions are greatly appreciated.
    Maximilian

    Working backwards...
    Assuming all the files have the same name structure (e.g. end in the format "xxx~xxx.jpg" you can get the base name using:
    <pre class=command>set baseName to characters 1 through -13 of filename as text</pre>
    This cuts off the last 12 characters of the file name.
    Once you have a folder, you can get the names of files in the folder via the Finder. for sanity's sake I'd ask the Finder for the first item, just in case there's more than one file:
    <pre class=command>set filname to name of first item of (files of folder theFolder)</pre>
    And if all the folders are in one top folder, you can iterate through them like:
    <pre class=command>repeat with eachFolder in (every folder of folder topFolder)</pre>
    So now, string it all together:
    <pre class=command>tell application "Finder" -- we'll use the Finder to do the legwork
    set topFolder to (choose folder with prompt "Choose the top level folder" ) -- get the top folder
    repeat with eachFolder in (every folder of folder topFolder)
    set fileName to name of first file of (files of folder topFolder)
    set baseName to characters 1 through -13 of fileName as text
    set name of folder eachFolder to baseName
    end repeat
    end tell</pre>
    Note there's no error checking - the script will fail if there are no files in any particular folder, but it should get you going.

  • How to find out the table name

    hi,
    how to find out the table name in which the data from a particular structure in a particular screen is saved,
    please tell me the procedure to find out the table name for saving the structure data that is inputted at runtime.
    Thanks,
    chinnu

    Hi Chinnu,
    Below are the tables that are referred to find out the table names
    DD02L Table contains the SAP Tables.
    DD02T Table contains the SAP Table Texts.
    DD01L Table contains the Domains
    DD01T Table contains the Domain Texts.
    DD03L Table contains the Table Fields.
    DD03T Table contains the Table Field Texts. (Language Dependent)
    DD04L Table contains the Data Elements.
    DD04T Table contains the Data Element Texts.
    DD05s Table contains the Foreign Key Fields
    last words with L and T only. L->Database Fetch T-> Text
    And the procedure to retrive the table name is as follows
    1. Go to se11
    2. Enter table name DD03T and execute
    3. In the next screen you can find Tables, fields, test etc. there you can enter the field name in the fields 
      and execute.
    4. you can get all tables which contains the field.
    I hope this will solve your problem
    Regards,
    Chandru

Maybe you are looking for

  • Attachments cannot be opened by recipients

    I decided to use Mac Mail with my new intel iMac rather than Entourage. But now people on windows-based machines cannot open my Word attachments. This is why I went to Entourage on my old Mac. Argghhh. I have checked "always send windows-friendly att

  • Flash-Based BBC h264 Videos Freeze After 8 Seconds

    Hello, I like to view BBC news videos since March on my new Desktop Windows 7 64 bit Pro system.  For about 2 weeks now, I've been having trouble viewing about half of these videos.  Half play all the way through fine and the other half freeze after

  • Ways to consider the stocks provided to vendor on the MRP output

    Hi Gurus, I have a requirement where the business want the stocks provided to vendor to be considered when running the MRP in plant. This is a subcontracting vendor and when checking the MD04, the stocks was displayed as special stocks. Is there any

  • Manual input of NF Raw Material charge Rate (VF01)

    Hi All, Is there a way of letting the users input their own raw material charge rate at billing time ( NF Raw material Charging screen in VF01 ). I changed the field to an input field via customizing but when I run VF01 and I input my own value, the

  • CORBA Failover

    I have a java system that is connecting to a C++ server using a corba connection. I am using an IOR string generated by the C++ server to resolve the host/port and whatnot. I am trying to find a way to have this connection failover to a secondary ide