hello, I`m using this code, but it return files in alphabetic order, I need to list those files in date modified order. string winDir = "../katalogas"; try { string[] files = Directory.GetFiles(winDir); foreach (string fileName in files) { // // } } catch (IOException ex) { MessageBox.Show("Klaida! Nerandamas formų katalogas." + ex.Message); Close(); } }
valiovalio
Posts
-
list files in directory ordered by creation time -
Removing components from controlsnow it`s working, thank you very much.
-
Removing components from controlsHello, in runtime I create compoments (labels, checkboxs) later I want to clear those, but method that i`m using remove only half of them. Here is that method: foreach (Control ctrl in Controls) { if (ctrl is Label) { Controls.Remove(ctrl); } }
-
problems with INSERT to databasedifferent record every time, for example now it stoped after inserting second record: in table kodas is nvarchar 100; liga is nvarcha 150; INSERT INTO TLK (kodas, liga) VALUES ('A69.9', 'Spirochetu sukelta infekcija, nepatikslinta') INSERT INTO TLK (kodas, liga) VALUES ('A70', 'Papugu chlamidiju infekcija') INSERT INTO TLK (kodas, liga) VALUES ('A70-A74', 'Kitos chlamidiju sukeltos ligos')
-
problems with INSERT to databaseHi, I want to insert into my database some information, I have everything in file a.txt: INSERT INTO TLK (kodas, liga) VALUES ('(01-99)', 'Traumu priežastys (ne iš TLK10 klasifikacijos)') INSERT INTO TLK (kodas, liga) VALUES ('01-99', 'Ne TLK10 traumu priežasciu klasifikacija') INSERT INTO TLK (kodas, liga) VALUES ('1', 'Transporto ivykis') a.txt contains about 10 000 records. I run this program, but everytime it breaks, it shows error that data would be truncated... how can I fix that? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace Kikilis { public partial class Form1 : Form { public Form1() { InitializeComponent(); } string eilute; int id = 0; StringBuilder errorMessages = new StringBuilder(); private void button1_Click(object sender, EventArgs e) { try { System.IO.StreamReader sr = new System.IO.StreamReader("a.txt"); eilute = sr.ReadLine(); string j = "Data Source=KOMPAS;Initial Catalog=MEDIS;Integrated Security=True"; SqlConnection c = new SqlConnection(j); c.Open(); while (eilute != "" || eilute == null) { SqlCommand cmd = new SqlCommand(eilute, c); cmd.ExecuteNonQuery(); cmd.Dispose(); eilute = sr.ReadLine(); } c.Close(); } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); } } } }
-
component propertySorry everything is now working:) thank you very much
-
component propertyFirst of all thank you for your answer, but I get this error An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Controls.get'
-
component propertyHi, how I can acces properties of component I created: I create 2 label in my form1, and later I want to get text from each of those labels I think it should look like this foreach(Label l in Form1.label) { console.write(l.text); } but I`m wrong...
-
list all tables names in comboboxthank You:)
-
list all tables names in comboboxHi, I want to list all tables names in combobox. Can somebody write a code example. Thank you:)
-
problems connecting to local databaseI don`t think it`s a problem with connection string... I`m not able to connect no mathet what I write in that connection string...
-
problems connecting to local databaseYou meant 'AttachDbFilename=db.mdf;'?
-
problems connecting to local databaseHi, I`m using visual studio 2005. I`ve created a local database "db.mdf", and I`m just trying to connect with, but when I run code it throws an exception: ServerVersion = 'sqlconn.ServerVersion' threw an exception of type 'System.InvalidOperationException' and after that the program stops to respond...What should I do to connect? here is my code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace DB { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string c = "Data Source=(local);database=db.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; SqlConnection sqlconn = new SqlConnection(c); sqlconn.Open(); string query = "SELECT ASM_VARDAS, ASM_PAVARDE, ASM_GIM_DATA FROM v_ASMENYS WHERE ASM_AK = "; SqlCommand sqlcomm = new SqlCommand(query, sqlconn); SqlDataReader reader = sqlcomm.ExecuteReader(); reader.Read(); } } }
-
image doesn`t fit to screenI display image in usual way, so I do have a big problem:( unless there is, maybe some way to shrink that image or something... Or what should I do? Maybe there is something I can do while scaning image, setting some properties...? I just don`t know what to do, I need to open image in real size. Maybe you can suggest something? Thanks:)
-
image doesn`t fit to screenstring kelias; Bitmap image1; kelias = OpenFile(); image1 = new Bitmap(@kelias, true); // how to set the size in centimetres? } //----------------------------------------------------------------- private string OpenFile() { OpenFileDialog dlgOpenFile = new OpenFileDialog(); dlgOpenFile.ShowReadOnly = true; if (dlgOpenFile.ShowDialog() == DialogResult.OK) { string path = dlgOpenFile.FileName; return path; } return null; }
-
image doesn`t fit to screenhello, I have an image with properties: Size: 1520 x 2234 pixels DPI = 200; size in centimetres: 19.3 x 28.4 cm When I open that image, it doesn`t fit to my 17' screen:( That image fits with size in centimetres. Is it possible to open that picture with size in centimetres, but not in pixels? Arnas
-
Image propertiesThanks, You very helped me.
-
Image propertiesHello, I`m scaned a picture and set the size height 10cm width 10cm, now when I load that picture, I can`t find these parameters, I can only find number of pixels, but nothing about size in centimetres. sring path; Bitmap image1; path= OpenFile(); image1 = new Bitmap(@path, true); } //--------------------------------------- private string OpenFile() { OpenFileDialog dlgOpenFile = new OpenFileDialog(); dlgOpenFile.ShowReadOnly = true; if (dlgOpenFile.ShowDialog() == DialogResult.OK) { string path = dlgOpenFile.FileName; return path; } return null; }
-
Drag and dropThanks;) now it work:)
-
Drag and dropHello, I`m trying to create label and then I`m trying to move it on the form, but when I drag label I see two labels instead of one. what should I do to fix it? bool a; Label l; private void button1_Click(object sender, EventArgs e) { l = new Label(); l.Text = "text"; Controls.Add(l); l.MouseDown += new System.Windows.Forms.MouseEventHandler(mouse_down); l.MouseUp += new System.Windows.Forms.MouseEventHandler(mouse_up); l.MouseMove += new System.Windows.Forms.MouseEventHandler(mouse_move); Form1.ActiveForm.AllowDrop = true; } private void mouse_down(object sender, MouseEventArgs e) { a = true; } private void mouse_up(object sender, MouseEventArgs e) { a = false; } private void mouse_move(object sender, MouseEventArgs e) { if (a) { l.Location = e.Location; } } arnas