c#-2.0

Rename a file in C# (NET 2.0) without moving it or using DOS / Visual Basic commands

无人久伴 提交于 2019-12-11 19:34:18
问题 I have not found yet a file-rename-function in .NET for C#, so I'm a bit confused how I would rename a file. I use the command prompt with Process.Start, but this isn't really professional and a black DOS window is popping up each time. Yes, I know there is something in the Visual Basic namespace, but this is not my intention to add the "visual-basic.dll" to my project. I found some examples which "move" the file to rename it. It is a quite painful method and a shoddy workaround for things.

how to select xmlelements xmlnodes xmlattributes of specified values on c# 2.0/3.0

和自甴很熟 提交于 2019-12-11 19:32:20
问题 here is my xml document that looks like this <?xml version="1.0" encoding="UTF-8"?> <bookstore> <book category="cooking"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year updated="no" version="3.5">2005</year> <price>30.00</price> </book> <book category="children"> <title lang="fr">Harry Potter</title> <author>J K. Rowling</author> <year updated="yes" version="2.0">2005</year> <price>29.99</price> </book> </bookstore> 1-how to select all books and print

C# Sending GridViews/DataTables via Email

牧云@^-^@ 提交于 2019-12-11 16:21:59
问题 I'm trying the find the best way to send a GridView or DataTable in an email. Page Behind Code: protected void Page_Load(object sender, EventArgs e) { DataTable s1 = Sql.specificReportData(Convert.ToInt32(Session["userID"])); this.gv.DataSource = s1.DefaultView; this.gv.DataBind(); } This generates and binds the data successfully, but if I try and add the contents of gv to a HTML encoded email then the gv part of the email is blank. Do I need to alter the GridView so it's HTML compliant? I

How to enum another process modules in Windows XP 64bit

时间秒杀一切 提交于 2019-12-11 13:54:51
问题 I already asked how to enum 32bit process modules from a 64bit process here. And the answer was EnumProcessModulesEx. All works fine on Windows 7 x64, but what about Windows XP x64? It seems that this api is supported on Vista and up. So what's the way to do it there? 回答1: CreateToolHelp32Snapshot will do it. 回答2: Probably something like this. Wrote it in notepad so might be wrong. But you get the idea. HANDLE hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID ); MODULEENTRY32

How to validate combo box values in c# [closed]

匆匆过客 提交于 2019-12-11 13:47:26
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have 6 combo boxes in c# form that all fill from database from same column. i-e for making student result combo boxes fill subject names. now I want is how to delete Subject name from 2nd combo box if the

itextsharp images are not coming next to one another

為{幸葍}努か 提交于 2019-12-11 13:13:15
问题 I have 2 asp.net chart control which i want to convert to pdf. I am using iTextSharp to convert the images to pdf. The issue is with the position of images, i want images to come next to other. i tried to setpagesize but it didnt worked. Document pdfDoc = new Document(PageSize.A4); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); Chart1.SaveImage(stream, ChartImageFormat.Png); iTextSharp.text.Image chartImage = iTextSharp.text

XDocument for .Net 2.0?

不羁岁月 提交于 2019-12-11 11:14:05
问题 I have some .Net 3.5 code that uses the XDocument class. Can you suggest a quick and dirty way to get this code running in .Net 2.0? public static HaarClassifierCascade Parse(XDocument xDoc) { HaarClassifierCascade cascade = null; XElement stages_fn; XElement seq_fn = null; /* sequence */ XElement fn; int n; int i = 0, j = 0, k = 0, l = 0; int parent, next; stages_fn = xDoc.Descendants(stageId).First(); n = stages_fn.Elements().Count(); cascade = new HaarClassifierCascade(n); seq_fn = xDoc

How to solve this ComboBox item setting problem?

我只是一个虾纸丫 提交于 2019-12-11 10:35:52
问题 This code is not setting right value to the combobox. This is because, those are from different contexts. In addition, in my actual problem, neither overloading == in nor overriding Equals() in MyClass is working as well. Any alternative way? How to solve this problem? MyClass.cs public class MyClass { public int ID { get; set; } public string Name { get; set; } public MyClass(int id, string name) { ID = id; Name = name; } public static List<MyClass> Get() { return new List<MyClass> { new

StackoverflowException in IIS7 but not in Cassini

…衆ロ難τιáo~ 提交于 2019-12-11 07:34:07
问题 I have some C# code that is giving a StackOverflowException when running under IIS7 but when it is run under Cassini in VS2008 then the code runs fine. Is this a known issue whereby Cassini handles these kinds of exceptions differently? 回答1: The IIS runtime uses a different stack size for threads. IIRC it is 256 KB as opposed to the standard 1 MB you get when running on the standard .NET runtime, which is the one VS uses. In other words, you may have code that runs fine under the regular .NET

String was not recognized as a valid DateTime in C# asp.net

随声附和 提交于 2019-12-11 06:56:27
问题 I want to import date value from excel cell. cell value having "10 October 2013" format. I want to convert it to datetime data type. My code getting error "string was not recognized as a valid datetime" //code OleDbCommand olecmd = new OleDbCommand("select * from [Sheet1$]", olecon); OleDbDataReader olerdr = olecmd.ExecuteReader(); while (olerdr.Read()) { deldate = olerdr.GetValue(13).ToString(); using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["irisdb"]