c#-4.0

How to get around Marshal.Copy (32bit) length limit?

时光怂恿深爱的人放手 提交于 2020-01-03 08:24:49
问题 I'm trying to move data back/forth between managed (C#) and unmanaged (C++ Win32) code. I can use Marshal.Copy and it works just fine until the datasets get bigger > 2GB as Marshal.Copy has a signed 32 bit int (2GB) limit for length. Any idea how to get around this? Currently I use AllocHGlobal(IntPtr) on the managed side and .ToPointer() on the unmanaged side. If I can't use Marshal.Copy to move large data (> 2GB) back/forth what can I use? 回答1: My first reaction was: why are your copying

Deselect text in a textbox

我只是一个虾纸丫 提交于 2020-01-03 07:27:33
问题 I have a windows form that sets the text property in a textbox to that of a string variable. When the form is ran, it has all of the text in the textbox selected. I need to try and figure out how to keep that from happening. I tried the DeslectAll() method on the textbox but that doesn't seem to work. I also tried txtBox.SelectNextControl(txtCostSummary, true, false, true, true); but I kind of was guessing on what the paramters needed to be set to, tweaking them doesn't seem to make a

Get key from value - Dictionary<string, List<string>>

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-03 07:26:04
问题 I am having trouble getting the key by specifying a value. What is the best way I can achieve this? var st1= new List<string> { "NY", "CT", "ME" }; var st2= new List<string> { "KY", "TN", "SC" }; var st3= new List<string> { "TX", "OK", "MO" }; var statesToEmailDictionary = new Dictionary<string, List<string>>(); statesToEmailDictionary.Add("test1@gmail.com", st1); statesToEmailDictionary.Add("test2@gmail.com", st2); statesToEmailDictionary.Add("test3@gmail.com", st3); var emailAdd =

Problems to desearilize a JSON my class is always null

∥☆過路亽.° 提交于 2020-01-03 05:52:25
问题 I've got the following JSON: {"workspaces":{ "workspace":[ {"name":"Berlin","href":"http://10.80.14.188:8080/geoserver/rest/workspaces/Berlin.json"}, {"name":"Paris","href":"http://10.80.14.188:8080/geoserver/rest/workspaces/Paris.json"}, {"name":"Rome","href":"http://10.80.14.188:8080/geoserver/rest/workspaces/Rome.json"}, {"name":"London","href":"http://10.80.14.188:8080/geoserver/rest/workspaces/London.json"}, {"name":"usa","href":"http://10.80.14.188:8080/geoserver/rest/workspaces/usa

Search for a folder by its name in c# without specifying the path

狂风中的少年 提交于 2020-01-03 05:14:06
问题 I want to search a folder by its name. But I don't know the location of the folder. Have to get the path of that specific folder. How Can i do it? 回答1: You have to specify the directory to search for the folder using Directory.GetDirectories Method (String, String, SearchOption) string[] directories = Directory.GetDirectories(@"c:\", "*", SearchOption.AllDirectories); To get all drives from the computer, use DircotoryInfo.GetDrives and then search in all of them you can try: DriveInfo[]

Gracefully killing a TPL Task

你离开我真会死。 提交于 2020-01-03 04:48:11
问题 I'm attempting to build an API like thing against a set of REST services. There are basically different operations that report their progress and support cancelation. I opted to use the TPL to make async functions and managed load. Here is my most basic operation that is to be inherited accordingly: using FileOnlineCore.Enums; using FileOnlineCore.EventArguments; using FileOnlineCore.Events; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using

Preserve dynamically generated check box's value on postback

…衆ロ難τιáo~ 提交于 2020-01-03 04:21:04
问题 In my Online Registration application, I've created two models as below. TeamModel is used to store information regarding the team and project while MemberModel will contain information regarding the members of the team. public class MemberModel { [Display(Name = "Member Name")] public string MemberName { get; set; } [Display(Name = "Speciality")] public string Speciality { get; set; } public bool IsLeader { get; set; } } public class TeamModel { [Display(Name = "Team Name")] public string

C#-Wait for IE to load?

眉间皱痕 提交于 2020-01-03 03:20:09
问题 I'm opening a URL in a web browser using the following code: Process p = new Process(); p.StartInfo.FileName = GetDefaultBrowserPath(); //gets path to default browser from the registry p.StartInfo.Arguments = "htp://www.google.com"; p.Start(); Can someone tell me how I would wait for IE to be loaded? Is this the correct way to go about this? Thanks, Jimmy 回答1: Just do this: Process.Start("http://www.google.com"); It'll open it in the default browser. 回答2: This might be what you're looking for

C#-Wait for IE to load?

人盡茶涼 提交于 2020-01-03 03:20:07
问题 I'm opening a URL in a web browser using the following code: Process p = new Process(); p.StartInfo.FileName = GetDefaultBrowserPath(); //gets path to default browser from the registry p.StartInfo.Arguments = "htp://www.google.com"; p.Start(); Can someone tell me how I would wait for IE to be loaded? Is this the correct way to go about this? Thanks, Jimmy 回答1: Just do this: Process.Start("http://www.google.com"); It'll open it in the default browser. 回答2: This might be what you're looking for

Move file onto network share (via impersonation) C#

这一生的挚爱 提交于 2020-01-03 03:03:49
问题 I have been working on a project in C# (.net4). Project pretty much allows people to upload files from their local machine to a network share. Network share is secured. It is only accessible by user called "proxy" which is created in active directory. I did some research and I found this class which I used for impersonation. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; using System.Security.Principal; namespace