c#-4.0

Executing powershell scripts in c#

£可爱£侵袭症+ 提交于 2020-05-15 02:08:18
问题 Below is the script I am using to try and execute my powershell script but whenever i run it i just get a blank command window. C# Code static void Main(string[] args) { string text = System.IO.File.ReadAllText(@"C:\Program Files (x86)\Backup Reporter\Required\edit_website.ps1"); using (PowerShell PowerShellInstance = PowerShell.Create()) { // use "AddScript" to add the contents of a script file to the end of the execution pipeline. // use "AddCommand" to add individual commands/cmdlets to

Selenium WebDriver C# - get text

倖福魔咒の 提交于 2020-05-13 06:21:27
问题 I have this Html element on the page: <li id="city" class="anketa_list-item"> <div class="anketa_item-city">From</div> London </li> I found this element: driver.FindElement(By.Id("city")) If I try: driver.FindElement(By.Id("city")).Text , => my result: "From\r\nLondon". How can I get only London by WebDriver? 回答1: You could easily get by using class-name : driver.FindElement(By.Class("anketa_item-city")).Text; or using Xpath driver.FindElement(By.Xpath("\li\div")).Text; 回答2: You can try this:

Selenium WebDriver C# - get text

十年热恋 提交于 2020-05-13 06:20:26
问题 I have this Html element on the page: <li id="city" class="anketa_list-item"> <div class="anketa_item-city">From</div> London </li> I found this element: driver.FindElement(By.Id("city")) If I try: driver.FindElement(By.Id("city")).Text , => my result: "From\r\nLondon". How can I get only London by WebDriver? 回答1: You could easily get by using class-name : driver.FindElement(By.Class("anketa_item-city")).Text; or using Xpath driver.FindElement(By.Xpath("\li\div")).Text; 回答2: You can try this:

xml Convert.ToDouble works wrong

感情迁移 提交于 2020-04-07 00:34:21
问题 I have a project that reads some data from xml file Convert.ToDouble metod works wrong. it converts 0.05 as 5. is there any idea to solve this problem? this is my ReadDataFromXml method: public static List<double> XmldenTabanDegerleriniOku(string ID) { string ayarDir = System.Environment.CurrentDirectory + "\\Ayarlar"; string Dosya = ayarDir + "\\YuzeyBoyutlari.xml"; XmlDocument doc = new XmlDocument(); doc.Load(Dosya); XmlNodeList holList = doc.GetElementsByTagName("HOL"); List<double>

xml Convert.ToDouble works wrong

依然范特西╮ 提交于 2020-04-07 00:28:44
问题 I have a project that reads some data from xml file Convert.ToDouble metod works wrong. it converts 0.05 as 5. is there any idea to solve this problem? this is my ReadDataFromXml method: public static List<double> XmldenTabanDegerleriniOku(string ID) { string ayarDir = System.Environment.CurrentDirectory + "\\Ayarlar"; string Dosya = ayarDir + "\\YuzeyBoyutlari.xml"; XmlDocument doc = new XmlDocument(); doc.Load(Dosya); XmlNodeList holList = doc.GetElementsByTagName("HOL"); List<double>

xml Convert.ToDouble works wrong

限于喜欢 提交于 2020-04-07 00:26:33
问题 I have a project that reads some data from xml file Convert.ToDouble metod works wrong. it converts 0.05 as 5. is there any idea to solve this problem? this is my ReadDataFromXml method: public static List<double> XmldenTabanDegerleriniOku(string ID) { string ayarDir = System.Environment.CurrentDirectory + "\\Ayarlar"; string Dosya = ayarDir + "\\YuzeyBoyutlari.xml"; XmlDocument doc = new XmlDocument(); doc.Load(Dosya); XmlNodeList holList = doc.GetElementsByTagName("HOL"); List<double>

xml Convert.ToDouble works wrong

坚强是说给别人听的谎言 提交于 2020-04-07 00:21:30
问题 I have a project that reads some data from xml file Convert.ToDouble metod works wrong. it converts 0.05 as 5. is there any idea to solve this problem? this is my ReadDataFromXml method: public static List<double> XmldenTabanDegerleriniOku(string ID) { string ayarDir = System.Environment.CurrentDirectory + "\\Ayarlar"; string Dosya = ayarDir + "\\YuzeyBoyutlari.xml"; XmlDocument doc = new XmlDocument(); doc.Load(Dosya); XmlNodeList holList = doc.GetElementsByTagName("HOL"); List<double>

Sorting GridView Formed With Data Set

99封情书 提交于 2020-03-25 08:40:07
问题 The following code sample is for sorting a GridView formed With a DataSet . Source: http://www.highoncoding.com/Articles/176_Sorting_GridView_Manually_.aspx But it is not displaying any output. There is no problem in sql connection. I am unable to trace the error, please help me. Thank You. public partial class _Default : System.Web.UI.Page { private const string ASCENDING = " ASC"; private const string DESCENDING = " DESC"; private DataSet GetData() { SqlConnection cnn = new SqlConnection(

Access Ironpython dictionary from C#

末鹿安然 提交于 2020-03-23 07:00:48
问题 I have dictionary defined in Ironpython script and I want to access this dictionary from my C# code. Can someone provide example code to achieve my requirement. Sorry earlier I did not mention my problem statement with code. import clr clr.AddReference("System.Core") import System clr.ImportExtensions(System.Linq) from System.Collections.Generic import Dictionary,List def check(self): dict1 = Dictionary[str,str] dict1["a"] = "aa" dict2 = Dictionary[str,str] dict2["b"] = "bb" self[0] = dict1 #

ConcurrentDictionary TryGetValue vs []. Is [] still thread-safe?

坚强是说给别人听的谎言 提交于 2020-03-18 03:37:07
问题 I have the following ConcurrentDictionary : ConcurrentDictionary<Guid, Session> sessions; I know that sessions.TryGetValue(key, out session) is thread-safe, but my question is if sessions[key] is also thread-safe? sessions.TryGetValue(key, out session) returns true or false depending on whether it was able to get the value or not. Will sessions[key] return null if it is unable to get the value? I would think so. Can anyone confirm or shed more light on this? Thanks. 回答1: It is thread-safe,