Skip to main content
updated
Source Link
Amal Hashim
  • 28.4k
  • 5
  • 32
  • 61

I am uploading files on a SharePoint folder with this code:

var clientContext = GetClientContext();
var folderName = "Folder";
var fileName = @"C:\Users\user\Desktop\file.pdf";
folder = clientContext.Web.Folders.GetByUrl(clientContext.Url + '/' + folderName);
var info = new FileCreationInformation
            {
                ContentStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read),
                Overwrite = false,
                Url = clientContext.Url + '/' + folderName + '/' + Path.GetFileName(fileName),
            };
file = folder.Files.Add(info);
folder.Update();
clientContext.Load(file, f => f.ListItemAllFields);
clientContext.ExecuteQuery();
clientContext.Load(file);
fileID = file.ListItemAllFields.Id;

..and And I see that they have no title once they get uploaded (they only have a name).

How can I set the titleTitle too?

I am uploading files on a SharePoint folder with this code:

var clientContext = GetClientContext();
var folderName = "Folder";
var fileName = @"C:\Users\user\Desktop\file.pdf";
folder = clientContext.Web.Folders.GetByUrl(clientContext.Url + '/' + folderName);
var info = new FileCreationInformation
            {
                ContentStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read),
                Overwrite = false,
                Url = clientContext.Url + '/' + folderName + '/' + Path.GetFileName(fileName),
            };
file = folder.Files.Add(info);
folder.Update();
clientContext.Load(file, f => f.ListItemAllFields);
clientContext.ExecuteQuery();
clientContext.Load(file);
fileID = file.ListItemAllFields.Id;

..and I see that they have no title once they get uploaded (they only have a name).

How can I set the title too?

I am uploading files on a SharePoint folder with this code:

var clientContext = GetClientContext();
var folderName = "Folder";
var fileName = @"C:\Users\user\Desktop\file.pdf";
folder = clientContext.Web.Folders.GetByUrl(clientContext.Url + '/' + folderName);
var info = new FileCreationInformation
            {
                ContentStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read),
                Overwrite = false,
                Url = clientContext.Url + '/' + folderName + '/' + Path.GetFileName(fileName),
            };
file = folder.Files.Add(info);
folder.Update();
clientContext.Load(file, f => f.ListItemAllFields);
clientContext.ExecuteQuery();
clientContext.Load(file);
fileID = file.ListItemAllFields.Id;

And I see that they have no title once they get uploaded (they only have a name).

How can I set the Title too?

added 24 characters in body
Source Link

I am uploading files on a SharePoint folder with this code:

var clientContext = GetClientContext();
var folderName = "Folder";
var fileName = @"C:\Users\user\Desktop\file.pdf";
folder = clientContext.Web.Folders.GetByUrl(clientContext.Url + '/' + folderName);
var info = new FileCreationInformation
            {
                ContentStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read),
                Overwrite = false,
                Url = clientContext.Url + '/' + folderName + '/' + Path.GetFileName(fileName),
            };
file = folder.Files.Add(info);
folder.Update();
clientContext.Load(file, f => f.ListItemAllFields);
clientContext.ExecuteQuery();
clientContext.Load(file);
fileID = file.ListItemAllFields.Id;

..and I see that they have no title once they get uploaded (they only have a name).

How can I set the title too?

I am uploading files on a SharePoint folder with this code:

var clientContext = GetClientContext();
var folderName = "Folder";
var fileName = @"C:\Users\user\Desktop\file.pdf";
folder = clientContext.Web.Folders.GetByUrl(clientContext.Url + '/' + folderName);
var info = new FileCreationInformation
            {
                ContentStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read),
                Overwrite = false,
                Url = clientContext.Url + '/' + folderName + '/' + Path.GetFileName(fileName),
            };
file = folder.Files.Add(info);
folder.Update();
clientContext.Load(file, f => f.ListItemAllFields);
clientContext.ExecuteQuery();
clientContext.Load(file);
fileID = file.ListItemAllFields.Id;

..and I see that they have no title once they get uploaded.

How can I set the title too?

I am uploading files on a SharePoint folder with this code:

var clientContext = GetClientContext();
var folderName = "Folder";
var fileName = @"C:\Users\user\Desktop\file.pdf";
folder = clientContext.Web.Folders.GetByUrl(clientContext.Url + '/' + folderName);
var info = new FileCreationInformation
            {
                ContentStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read),
                Overwrite = false,
                Url = clientContext.Url + '/' + folderName + '/' + Path.GetFileName(fileName),
            };
file = folder.Files.Add(info);
folder.Update();
clientContext.Load(file, f => f.ListItemAllFields);
clientContext.ExecuteQuery();
clientContext.Load(file);
fileID = file.ListItemAllFields.Id;

..and I see that they have no title once they get uploaded (they only have a name).

How can I set the title too?

Source Link

How to upload a file in a folder and set it's title?

I am uploading files on a SharePoint folder with this code:

var clientContext = GetClientContext();
var folderName = "Folder";
var fileName = @"C:\Users\user\Desktop\file.pdf";
folder = clientContext.Web.Folders.GetByUrl(clientContext.Url + '/' + folderName);
var info = new FileCreationInformation
            {
                ContentStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read),
                Overwrite = false,
                Url = clientContext.Url + '/' + folderName + '/' + Path.GetFileName(fileName),
            };
file = folder.Files.Add(info);
folder.Update();
clientContext.Load(file, f => f.ListItemAllFields);
clientContext.ExecuteQuery();
clientContext.Load(file);
fileID = file.ListItemAllFields.Id;

..and I see that they have no title once they get uploaded.

How can I set the title too?