2

I am trying to get the name property of a file on SharePoint ?

If I try to get the metadata of the columns I created, I can get this data with this method

file is SPFile.

if (file.GetProperty("DocId") != null)
{
    docId = file.GetProperty("DocId").ToString();
}

But when I try to get the name

if (file.GetProperty("Name") != null)
{
    docId = file.GetProperty("Name").ToString();
}
else {...}

it goes to else statement.

Where do I go wrong?

Thanks.

David
  • 15,652
  • 26
  • 115
  • 156
kevin
  • 13,559
  • 30
  • 79
  • 104

2 Answers2

4

Most likely you want to look at properties of an SPItem associated with the SPFile in a document library - SPFile.GetListItem.

You can also enumerate all properties of the file with SPFile.Properties to see that name of "file name" property is something like "vti_title".

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
2

It's OK after I use

file.Item.Name;
kevin
  • 13,559
  • 30
  • 79
  • 104