SharepointUtility 1.0.1

dotnet add package SharepointUtility --version 1.0.1                
NuGet\Install-Package SharepointUtility -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SharepointUtility" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SharepointUtility --version 1.0.1                
#r "nuget: SharepointUtility, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SharepointUtility as a Cake Addin
#addin nuget:?package=SharepointUtility&version=1.0.1

// Install SharepointUtility as a Cake Tool
#tool nuget:?package=SharepointUtility&version=1.0.1                
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Security;

namespace SharepointUtilityTester
{
	public partial class SharepointUtilityTester : Form
	{
		public SharepointUtilityTester()
		{
			/**
			 * If Net Framework version is less than 4.7, SecurityProtocol must be set below
			 */
			ServicePointManager.SecurityProtocol =
				SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

			var statusStrip = new StatusStrip() { Parent = this, };
			var toolStripStatusLabel = new ToolStripStatusLabel() { Text = "Ready", TextAlign = ContentAlignment.MiddleLeft, Spring = true, };
			statusStrip.Items.Add(toolStripStatusLabel);

			TabControl tabControl = new TabControl() { Parent = this, Dock = DockStyle.Top, };


			ToolStrip toolStrip = new ToolStrip() { Parent = this, Dock = DockStyle.Top, };
			ToolStripButton toolStripButtonAdd = new ToolStripButton() { Text = "Add", AutoSize = false, Width = 200, Alignment = ToolStripItemAlignment.Right, BackColor = Color.Lime, };
			toolStrip.Items.Add(toolStripButtonAdd);

			toolStripButtonAdd.Click += (sender, e) =>
			{
				Form formAadd = new Form()
				{
					Text = "Add new connection",
					Font = SystemInformation.MenuFont,
					StartPosition = FormStartPosition.CenterScreen,
					Width = 600,
				};

				var panelheight = new TextBox().Height;
				Panel panelOKCancel = new Panel() { Parent = formAadd, Dock = DockStyle.Top, Height = panelheight, };
				Button buttonOK = new Button() { Parent = panelOKCancel, Text = "OK", DialogResult = DialogResult.OK, Dock = DockStyle.Right, };
				Button buttonCancel = new Button() { Parent = panelOKCancel, Text = "Cancel", DialogResult = DialogResult.Cancel, Dock = DockStyle.Right, };


				Panel panelShortcut = new Panel() { Parent = formAadd, Dock = DockStyle.Top, Height = panelheight * 5, };
				TextBox textBoxShortcut = new TextBox() { Parent = panelShortcut, Dock = DockStyle.Left, Multiline = true, Height = panelheight * 5, Text = "/foo/bar", };
				Label labelShortcut = new Label() { Parent = panelShortcut, Dock = DockStyle.Left, Text = "Shortcut serverRelativeUrl", };

				Panel panelPassword = new Panel() { Parent = formAadd, Dock = DockStyle.Top, Height = panelheight, };
				TextBox textBoxPassword = new TextBox() { Parent = panelPassword, Dock = DockStyle.Left, PasswordChar = '*', };
				Label labelPassword = new Label() { Parent = panelPassword, Dock = DockStyle.Left, Text = "Password", };
				Panel panelUserName = new Panel() { Parent = formAadd, Dock = DockStyle.Top, Height = panelheight, };
				TextBox textBoxUserName = new TextBox() { Parent = panelUserName, Dock = DockStyle.Left, };
				Label labelUserName = new Label() { Parent = panelUserName, Dock = DockStyle.Left, Text = "Username", };
				Panel panelUrl = new Panel() { Parent = formAadd, Dock = DockStyle.Top, Height = panelheight, };
				TextBox textBoxUrl = new TextBox() { Parent = panelUrl, Dock = DockStyle.Left, };
				Label labelUrl = new Label() { Parent = panelUrl, Dock = DockStyle.Left, Text = "Url", };
				textBoxPassword.Width = textBoxUrl.Width = textBoxUserName.Width = textBoxShortcut.Width = panelUrl.Width - labelUrl.Width;

				Action chk = ()=>
				{
					buttonOK.Enabled = !string.IsNullOrEmpty(textBoxUrl.Text) && !string.IsNullOrEmpty(textBoxUserName.Text);
				};
				textBoxUrl.TextChanged += (sender2, e2) => { chk(); };
				textBoxUserName.TextChanged += (sender2, e2) => { chk(); };
				chk();

				if (formAadd.ShowDialog() == DialogResult.OK)
				{
					if (string.IsNullOrEmpty(textBoxUrl.Text))
					{
						toolStripStatusLabel.Text = "Url is empty.";
						return;
					}
					if (string.IsNullOrEmpty(textBoxUserName.Text))
					{
						toolStripStatusLabel.Text = "Usernanme is empty.";
						return;
					}

					/** If SecureString is null, password input dialog is shown when connect */
					SecureString ss = null;
					if (!string.IsNullOrEmpty(textBoxPassword.Text))
					{
						ss = new SecureString();
						foreach (var c in textBoxPassword.Text) { ss.AppendChar(c); }
					}

					SharepointUtility.SharepointUtility sharePointUtility =
						new SharepointUtility.SharepointUtility(textBoxUrl.Text, textBoxUserName.Text, ss, (v) => { toolStripStatusLabel.Text = v; });
					TabPage page = new TabPage() { Text = textBoxUrl.Text, };
					page.Controls.Add(sharePointUtility.Panel);
					sharePointUtility.Panel.Dock = DockStyle.Fill;

					/** Add folder shortcut. The path is serverRelaativeUrl */
					ToolStripMenuItem toolStripMenuItemFolderList = new ToolStripMenuItem() { Text = "Shortcut", };
					foreach (var d in textBoxShortcut.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
					{
						var tsmi = new ToolStripMenuItem() { Text = d, };
						tsmi.Click += async (sender2, e2) =>
						{
							toolStripStatusLabel.Text = d;
							await sharePointUtility.ChangeFolder(d);
						};
						toolStripMenuItemFolderList.DropDownItems.Add(tsmi);
					}
					sharePointUtility.ToolStrip.Items.Add(toolStripMenuItemFolderList);


					/** Can add to contextmenu what you like */
					ToolStripMenuItem toolStripMenuItemGlimps = new ToolStripMenuItem() {Text="Glimps", };
					toolStripMenuItemGlimps.Click += async (sender2, e2) => 
					{
						foreach(var si in sharePointUtility.SelectedItems)
						{
							if(!si.IsDir)
							{
								var d = await sharePointUtility.DownloadBinary(si.ServerRelativeUrl);
								MessageBox.Show(Encoding.UTF8.GetString(d));
							}
						}
					};

					sharePointUtility.ContextMenuStrip.Items.Insert(0,toolStripMenuItemGlimps);
					sharePointUtility.ContextMenuStrip.Items.Insert(1, new ToolStripSeparator());

					tabControl.Controls.Add(page);


					toolStripStatusLabel.Text = "Added a new sharePointUtility ";
				}

			};





			Font = SystemInformation.MenuFont;
			SizeChanged += (sender, e) =>
			{
				tabControl.Height = ClientSize.Height - statusStrip.Height;
			};

			ClientSize = new Size(1200, 800);
			StartPosition = FormStartPosition.CenterScreen;
			Text = "SharepointUtility Tester";
		}
	}
}
Product Compatible and additional computed target framework versions.
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 185 7/16/2023
1.0.0 165 4/8/2023