I'm trying to create a Sharepoint Site using Sharepoint client namespaces, full code below
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 Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SPSite topLevelSite = new SPSite("http://localhost");
SPWeb spWebInstance = topLevelSite.OpenWeb();
String siteTemplate = spWebInstance.WebTemplate;
try
{
SharePointWebInstance.Webs.Add("the name", "name", "new site added", (UInt32)System.Globalization.CultureInfo.CurrentCulture.LCID, siteTemplate, false, false);
}
catch (Exception ex)
{
//...
}
finally
{
topLevelSite.Close();
SharePointWebInstance.Dispose();
}
}
}
}
And I'm getting a C# error at SharePointWebInstance.Webs.Add. Any thoughts?
You need to use the SPWeb object you have created, so it should be like this;
spWebInstance.Webs.Add("the name", "name", "new site added", (UInt32)System.Globalization.CultureInfo.CurrentCulture.LCID, siteTemplate, false, false);
And also make sure to update SPSite url address accordingly.
Related
I am new to C# and can't get OpenSlide to work. I need it to be able to read SVS files. Below is the code I have used. Is it possible I am missing something in a directory? My boss has used the same code and can get it to run without issue.
I am getting the following error:
OpenSlideNET.OpenSlideUnsupportedFormatException: 'Exception of type 'OpenSlideNET.OpenSlideUnsupportedFormatException' was thrown.'
using OpenSlideNET;
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;
namespace SVSCurrent1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenSlideImage image = OpenSlideImage.Open("C:\\projects\\SVS\\JP2K-33003-1.svs");
}
}
}
How to display the Hyperlink, Thumbnail, and Publish Date from the following RSS.XML Feed: https://www.economist.com/europe/rss.xml
I am trying to have the Hyperlink, Thumbnail and Publish Date from the feed above. How to go about this?
Below is my code that is displaying only the Title and Description:
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.Xml;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Web;
using System.ServiceModel.Syndication;
namespace RSS_Demo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
XmlReader FD_readxml = XmlReader.Create(textBox1.Text);
SyndicationFeed FD_feed = SyndicationFeed.Load(FD_readxml);
TabPage FD_tab = new TabPage(FD_feed.Title.Text);
tabControl1.TabPages.Add(FD_tab);
ListBox FD_list = new ListBox();
FD_tab.Controls.Add(FD_list);
FD_list.Dock = DockStyle.Fill;
FD_list.HorizontalScrollbar = true;
foreach(SyndicationItem FD_item in FD_feed.Items)
{
FD_list.Items.Add(FD_item.Title.Text);
FD_list.Items.Add(FD_item.Summary.Text);
FD_list.Items.Add("---------");
}
}
catch { }
}
}
}
With this code I can prevent a duplicate application from running the name given in the code .
But after the application is created, the name of that application (exe) can be changed and run multiple times in the same machine.
How to prevent it from running?
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;
namespace Demo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Text = "Demo";
int ac = System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count();
if (ac > 1)
{
MessageBox.Show("Application Already Running");
this.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World");
}
}
}```
Here is my code: I am trying to find the roblox PlayerBeta but its not working
I am not the best in coding but I found out how to find it but cant implent it right into the code
( EDIT ) The program works if I use the PID but that changes everytime I open up a new RobloxPlayerBeta ! so I cannot use that
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 Memory;
using System.Diagnostics;
namespace ForceField
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Mem MemLib = new Mem();
private void button1_Click(object sender, EventArgs e)
{
if (System.Diagnostics.Process.GetProcesses().Any((p) => p.ProcessName.Contains("RobloxPlayerBeta")))
{
int robloxPid = System.Diagnostics.Process.GetProcessesByName("RobloxPlayerBeta").FirstOrDefault().Id;
}
Console.WriteLine(robloxPid);
MemLib.writeMemory("0x184C3A98", "string", "PlsNoBan ");
Console.WriteLine(MemLib.readString("0x184C3A98"));
}
}
}
Omg I am stupid.. xD
I needed to do MemLib.OpenGameProcess(robloxPid)
I have two forms: one has a listbox with a list<>. I need to access the selected item of this textbox on a second form.
First form(GestaoJogadores_Admin):
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;
namespace WindowsFormsApplication1
{
public partial class GestaoJogadores_Admin : Form
{
private DiagramaEntidadesContainer dbATMT;
public GestaoJogadores_Admin()
{
InitializeComponent();
dbATMT = new DiagramaEntidadesContainer();
RefreshListaJogadores();
}
private void button_editarGestaoJogadores_Click(object sender, EventArgs e)
{
EditarJogador_Admin EditarJogadorAdmin = new EditarJogador_Admin();
Player jogadorSelecionado = (Player)lb_Jogadores.SelectedItem;
DialogResult resultado = EditarJogadorAdmin.ShowDialog();
}
}
}
Second form(EditarJogador_Admin)
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;
namespace WindowsFormsApplication1
{
public partial class EditarJogador_Admin: Form
{
private DiagramaEntidadesContainer dbATMT;
public EditarJogador_Admin()
{
InitializeComponent();
dbATMT = new DiagramaEntidadesContainer();
}
private void button_EditarJogadorOk_Click_1(object sender, EventArgs e)
{
GestaoJogadores_Admin GestaoJogadoresAdmin = new GestaoJogadores_Admin();
Player jogadorSelecionado = (Player)GestaoJogadoresAdmin.jogadorSelecionado;//this is what I need, but it doenst work. I get an errror: 'GestaoJogadores_Admin' does not contain a definition for 'jogadorSelecionado' and no extension method 'jogadorSelecionado' accepting a first argument of type 'GestaoJogadores_Admin' could be found (are you missing a using directive or an assembly reference?)`
}
}
}
I open my second form creating an instance of it on the first one and using ShowDialog. On the second on, I thought that if I did the same and tried to access the "jogadorSelecionado" inside of it, It would work, but It doesnt...
In your first form on the button change
Player jogadorSelecionado = (Player)lb_Jogadores.SelectedItem;
try
EditarJogadorAdmin.passFromFormOne = (Player)lb_Jogadores.SelectedItem;
And on your second form add the variable to pass it too.
public Player passFromFormOne;
then
Player jogadorSelecionado = passFromFormOne;