C# how to copy all files in a folder

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();
         }
    }
}

C# MySQL read and insert in BLOB field

//Save
//-----------------------------------
MySql.Data.MySqlClient.MySqlConnection conn;
MySql.Data.MySqlClient.MySqlCommand cmd;

conn = new MySql.Data.MySqlClient.MySqlConnection();
cmd = new MySql.Data.MySqlClient.MySqlCommand();

string SQL;
UInt32 FileSize;
byte[] rawData;
FileStream fs;

conn.ConnectionString = "server=127.0.0.1;uid=root;" +
    "pwd=12345;database=test;";

try
{
    fs = new FileStream(@"c:\image.png", FileMode.Open, FileAccess.Read);
    FileSize = fs.Length;

    rawData = new byte[FileSize];
    fs.Read(rawData, 0, FileSize);
    fs.Close();

    conn.Open();

    SQL = "INSERT INTO file VALUES(NULL, @FileName, @FileSize, @File)";

    cmd.Connection = conn;
    cmd.CommandText = SQL;
    cmd.Parameters.AddWithValue("@FileName", strFileName);
    cmd.Parameters.AddWithValue("@FileSize", FileSize);
    cmd.Parameters.AddWithValue("@File", rawData);

    cmd.ExecuteNonQuery();

    MessageBox.Show("File Inserted into database successfully!",
        "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

    conn.Close();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
    MessageBox.Show("Error " + ex.Number + " has occurred: " + ex.Message,
        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

//Read
//-------------------------------------------------------------------------

MySql.Data.MySqlClient.MySqlConnection conn;
MySql.Data.MySqlClient.MySqlCommand cmd;
MySql.Data.MySqlClient.MySqlDataReader myData;

conn = new MySql.Data.MySqlClient.MySqlConnection();
cmd = new MySql.Data.MySqlClient.MySqlCommand();

string SQL;
UInt32 FileSize;
byte[] rawData;
FileStream fs;

conn.ConnectionString = "server=127.0.0.1;uid=root;" +
    "pwd=12345;database=test;";

SQL = "SELECT file_name, file_size, file FROM file";

try
{
    conn.Open();

    cmd.Connection = conn;
    cmd.CommandText = SQL;

    myData = cmd.ExecuteReader();

    if (! myData.HasRows)
        throw new Exception("There are no BLOBs to save");

    myData.Read();

    FileSize = myData.GetUInt32(myData.GetOrdinal("file_size"));
    rawData = new byte[FileSize];

    myData.GetBytes(myData.GetOrdinal("file"), 0, rawData, 0, FileSize);

    fs = new FileStream(@"C:\newfile.png", FileMode.OpenOrCreate, FileAccess.Write);
    fs.Write(rawData, 0, FileSize);
    fs.Close();

    MessageBox.Show("File successfully written to disk!",
        "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

    myData.Close();
    conn.Close();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
    MessageBox.Show("Error " + ex.Number + " has occurred: " + ex.Message,
        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

c# How to work with ini files

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);
        }
    }
}

c# scroll panel with picturebox by dragging mouse


private Point _StartPoint;
void pictureBox1_MouseDown(object sender, MouseEventArgs e) {
  if (e.Button == MouseButtons.Left)
    _StartPoint = e.Location;
}
void pictureBox1_MouseMove(object sender, MouseEventArgs e) {
  if (e.Button == MouseButtons.Left) {
    Point changePoint = new Point(e.Location.X - _StartPoint.X, 
                                  e.Location.Y - _StartPoint.Y);
    panel1.AutoScrollPosition = new Point(-panel1.AutoScrollPosition.X - changePoint.X,
                                          -panel1.AutoScrollPosition.Y - changePoint.Y);
  }
}
A Meaning (Prod. By Joel Johnston) by Hi-Rez on Grooveshark

c# create image with transparent background / c# Создание изображения с прозрачным бэкграундом

1)Use Bitmap.MakeTransparent()

Bitmap b = new Bitmap(ImageWithNonTransparentBackGround);
b.MakeTransparent(Color.Trasparent);

2)

var image = new Bitmap(135, 135, PixelFormat.Format32bppArgb);
using (var g = Graphics.FromImage(image)) {
g.Clear(Color.Transparent);
g.DrawLine(Pens.Red, 0, 0, 135, 135);
}

textblock wrap text font

Отличный мануал про это и всё другое http://msdn.microsoft.com/en-us/library/cc189010(v=vs.95).aspx

изучаем основы umbarco

Как добавить новый datatype в umbarco
1)руками
2)через wrapper
3)видео
4)динамик пропертис видео к этому

*как изменить default page в umbarco
просто поставить в дереве контента её на первое место

*как решить проблему по поводу того чтобы под разные девайсы и браузеры сжимался боди
вот что нашёл http://css-tricks.com/body-border/

*как добавить BingMap
да пожалйста,устанавливаем компонент и пишем
<form runat="server">
<umbraco:Macro bingMapNode="[#mainBingMap]" Alias="bingMapAdvanced" runat="server"></umbraco:Macro>
</form>

*как же это всё заделать под iphone
http://interpretor.ru/iphone_dev

*изменения размера шрифта от размера страницы
http://dimox.name/dynamic-font-size-on-jquery/

*что такое em pt %
http://www.askdev.ru/frontend/484/Размеры-в-em-ex-pt-px-в-чем-разница/

*какие же размеры экранов у девайсов
iphone - 320 х 480
ipad - 1024 x 768
у меня htc gratia 320x480 точно такое же как у iphone, так что можно тестировать

*как добавить bing map на свою страницу
http://msdn.microsoft.com/en-us/library/gg427610.aspx

*как вызвать один разор скрипт из другого
http://our.umbraco.org/forum/developers/razor/26993-Calling-Razor-from-Razor

*как узнать величину боди


*как чтобы div пальцем прокручивался на iphone
http://cubiq.org/iscroll

African Melody III (Melodia Africana III) by Ludovico Einaudi on Grooveshark