http://msdn.microsoft.com/ru-ru/library/wabtadw6.aspx пошаговое описание
http://msdn.microsoft.com/ru-ru/library/a65txexh.aspx сам мини кусок кода
Properties.Settings.Default.FirstUserSetting = "abc";
Properties.Settings.Default.Save();
using System.Data.OleDb; ... OleDbConnection _connection = new OleDbConnection(); StringBuilder ConnectionString = new StringBuilder(""); ConnectionString.Append(@"Provider=Microsoft.Jet.OLEDB.4.0;"); ConnectionString.Append(@"Extended Properties=Paradox 5.x;"); ConnectionString.Append(@"Data Source=D:\dbf;"); _connection.ConnectionString = ConnectionString.ToString(); try { _connection.Open(); } catch (Exception _e) { MessageBox.Show("Error openning database! " + _e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM kadr.db;", _connection); DataSet dsRetrievedData = new DataSet(); da.Fill(dsRetrievedData); this.dataGridView1.DataSource = dsRetrievedData; this.dataGridView1.DataMember = dsRetrievedData.Tables[0].TableName;
SqlCommand cmd = new SqlCommand("update table set bestOfTheBestField=@par where Na uslovie fantazii ne hvatilo"); cmd.Parameters.Add("@par", SqlDbType.Int).Value = (int)this.textBox.Text.Trim(); return cmd.ExecuteNonQuery();
// Declare the generic class. public class GenericList<T> { void Add(T input) { } } class TestGenericList { private class ExampleClass { } static void Main() { // Declare a list of type int. GenericList<int> list1 = new GenericList<int>(); // Declare a list of type string. GenericList<string> list2 = new GenericList<string>(); // Declare a list of type ExampleClass. GenericList<ExampleClass> list3 = new GenericList<ExampleClass>(); } }
string sourceDir = @"c:\current"; string backupDir = @"c:\archives\2008"; try { string[] picList = Directory.GetFiles(sourceDir, "*.jpg"); string[] txtList = Directory.GetFiles(sourceDir, "*.txt"); // Copy picture files. foreach (string f in picList) { // Remove path from the file name. string fName = f.Substring(sourceDir.Length + 1); // Use the Path.Combine method to safely append the file name to the path. // Will overwrite if the destination file already exists. File.Copy(Path.Combine(sourceDir, fName), Path.Combine(backupDir, fName), true); } // Copy text files. foreach (string f in txtList) { // Remove path from the file name. string fName = f.Substring(sourceDir.Length + 1); try { // Will not overwrite if the destination file already exists. File.Copy(Path.Combine(sourceDir, fName), Path.Combine(backupDir, fName)); } // Catch exception if the file was already copied. catch (IOException copyError) { Console.WriteLine(copyError.Message); } } // Delete source files that were copied. foreach (string f in txtList) { File.Delete(f); } foreach (string f in picList) { File.Delete(f); } } catch (DirectoryNotFoundException dirNotFound) { Console.WriteLine(dirNotFound.Message); }
using System; using System.Collections.Generic; using System.Text; using System.IO; namespace CopyDir { class Program { static void Main(string[] args) { string FromDir = @"c:\source"; string ToDir = @"c:\destination"; if (!Directory.Exists(ToDir)) Directory.CreateDirectory(ToDir); string[] Files; Files = Directory.GetFileSystemEntries(FromDir); for (int k = 0; k < Files.Length; k++) { string FromFile = Path.GetFileName(Files[k]); FileAttributes FileAttr = File.GetAttributes(Files[k]); if ((FileAttr & FileAttributes.Directory)== FileAttributes.Directory) continue; Console.WriteLine(FromFile); string arrival = ToDir + "\\" + FromFile; File.Copy(Files[k], arrival, true); } Console.ReadLine(); } } }