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();
// 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.Runtime.InteropServices; using System.Text; namespace sIniFile { /// <summary> /// Descrizione di riepilogo per IniFileClass. /// </summary> public class IniFileClass { private String IniFile = ""; // Importazione dei metodi dalle DLL di sistema [DllImport("kernel32")] private static extern long WritePrivateProfileInt(String Section, String Key, int Value, String FilePath); [DllImport("kernel32")] private static extern long WritePrivateProfileString(String Section, String Key, String Value, String FilePath); [DllImport("kernel32")] private static extern int GetPrivateProfileInt(String Section, String Key, int Default, String FilePath); [DllImport("kernel32")] private static extern int GetPrivateProfileString(String Section, String Key, String Default, StringBuilder retVal, int Size, String FilePath); public IniFileClass(String IniFile) { // Mi salvo il percorso del file INI this.IniFile = IniFile; } public String ReadString(String Section, String Key, String Default) { // Creo lo StringBuilder che conterra la stringa StringBuilder StrBu = new StringBuilder(255); // Provo a leggere il parametro richiesto GetPrivateProfileString(Section, Key, Default, StrBu, 255, IniFile); // Restituisco il parametro letto return StrBu.ToString(); } public int ReadInt(String Section, String Key, int Default) { // Restituisco il valore del parametro letto return GetPrivateProfileInt(Section, Key, Default, IniFile); } public void WriteString(String Section, String Key, String Value) { // Salvo il valore del parametro impostato WritePrivateProfileString(Section, Key, Value, IniFile); } public void WriteInt(String Section, String Key, int Value) { // Salvo il valore del parametro impostato WritePrivateProfileInt(Section, Key, Value, IniFile); } } }
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); message.To.Add("tomail@mail.ru"); message.Subject = "This is the Subject line"; message.From = new System.Net.Mail.MailAddress("frommail@mail.ru"); message.Body = "This is the message body"; System.Net.Mail.SmtpClient _SmtpClient = new System.Net.Mail.SmtpClient("smtp.mail.ru"); _SmtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; System.Net.NetworkCredential _NetworkCredential = new System.Net.NetworkCredential("smtpuser", "smtppassword"); _SmtpClient.UseDefaultCredentials = false; _SmtpClient.Credentials = _NetworkCredential;
_SmtpClient.Send(message);System.Net.Mail.Attachment attachment; attachment = new System.Net.Mail.Attachment("c:\\textfile.txt"); message.Attachments.Add(attachment);