while (FileExistsInFolder(context, documentsLibrary, newFileName))
{
fileCount++;
newFileName = $"{coreFileName} ({fileCount}){fileExtension}";
}
// uploading the file
using (FileStream fs = System.IO.File.OpenRead(filePath))
{
FileCreationInformation flciNewFile = new FileCreationInformation();
flciNewFile.ContentStream = fs;
flciNewFile.Url = newFileName;
flciNewFile.Overwrite = false;
Microsoft.SharePoint.Client.File uploadFile = documentsLibrary.Files.Add(flciNewFile);
context.Load(uploadFile);
context.ExecuteQuery();
}
image_url = $"https://<website>.sharepoint.com/{context.Web.ServerRelativeUrl}{siteAssetsUrl}/{newFileName}";
image_url = image_url.Replace(" ", "%20");
Console.WriteLine("Here is the url:\n" + image_url);
MessageBox.Show("This is the url (check console to copy):\n" + image_url);
}
else
{
image_url = string.Empty;
}
//Add new TQ to Register
ListItemCreationInformation newTQInfo = new ListItemCreationInformation();
ListItem newTQ = listObj.AddItem(newTQInfo);
newTQ["RaisedBy"] = Raisedby;
newTQ["Subject_x002f_Description"] = TQSubject.Text;
newTQ["ApplicableDrawing_x002f_ModelNum"] = TQDwgNo.Text;
newTQ["Area_x002f_Equipment"] = TQAreaEquip.Text;
newTQ["ParaMaticSuggestion"] = TQPMRemark.Text;
newTQ["DateRaised"] = dateTimePicker1.Value.ToString();
newTQ["ECRNumber"] = newTQNumber;
newTQ["ContractNumber"] = SelectedProjectItem;
// Attempting to update the attatchement folder
string fileName = "workTester.png";
byte[] fileBytes = System.IO.File.ReadAllBytes(imagePath);
newTQ["OverallImage1"] = fileBytes;
while (FileExistsInFolder(context, documentsLibrary, newFileName))
{
fileCount++;
newFileName = $"{coreFileName} ({fileCount}){fileExtension}";
}
// uploading the file
using (FileStream fs = System.IO.File.OpenRead(filePath))
{
FileCreationInformation flciNewFile = new FileCreationInformation();
flciNewFile.ContentStream = fs;
flciNewFile.Url = newFileName;
flciNewFile.Overwrite = false;
Microsoft.SharePoint.Client.File uploadFile = documentsLibrary.Files.Add(flciNewFile);
context.Load(uploadFile);
context.ExecuteQuery();
}
image_url = $"https://<website>.sharepoint.com/{context.Web.ServerRelativeUrl}{siteAssetsUrl}/{newFileName}";
image_url = image_url.Replace(" ", "%20");
Console.WriteLine("Here is the url:\n" + image_url);
MessageBox.Show("This is the url (check console to copy):\n" + image_url);
}
else
{
image_url = string.Empty;
}
//Add new TQ to Register
ListItemCreationInformation newTQInfo = new ListItemCreationInformation();
ListItem newTQ = listObj.AddItem(newTQInfo);
newTQ["RaisedBy"] = Raisedby;
newTQ["Subject_x002f_Description"] = TQSubject.Text;
newTQ["ApplicableDrawing_x002f_ModelNum"] = TQDwgNo.Text;
newTQ["Area_x002f_Equipment"] = TQAreaEquip.Text;
newTQ["ParaMaticSuggestion"] = TQPMRemark.Text;
newTQ["DateRaised"] = dateTimePicker1.Value.ToString();
newTQ["ECRNumber"] = newTQNumber;
newTQ["ContractNumber"] = SelectedProjectItem;
// Attempting to update the attatchement folder
string fileName = "workTester.png";
byte[] fileBytes = System.IO.File.ReadAllBytes(imagePath);
newTQ["OverallImage1"] = fileBytes;