<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Il blog di Pietro Libro</title>
        <link>http://blogs.ugidotnet.org/PietroLibroBlog/Default.aspx</link>
        <description />
        <language>it-IT</language>
        <copyright>Pietro Libro</copyright>
        <generator>Subtext Version 2.1.0.5</generator>
        <image>
            <title>Il blog di Pietro Libro</title>
            <url>http://blogs.ugidotnet.org/images/RSS2Image.gif</url>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Umbraco, importazione di file in Media</title>
            <category>CMS, Umbraco</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/29/umbraco-importazione-di-file-in-media.aspx</link>
            <description>&lt;p&gt;Con questo post inauguro (si fa per dire) una nuova sezione dedicata al CMS Open Source (scritto in C#) &lt;a href="http://www.umbraco.org/" target="_blank"&gt;Umbraco&lt;/a&gt;. Durante questa settimana, abbiamo avuto la necessità di migrare un vecchio sito verso questa piattaforma, il problema principale è stato l'importazione di documenti PDF all'interno della sezione Media di Umbraco, e agganciare l'ID del nodo media  di ogni file, al rispettivo controllo MediaPicker per i rispettivi documenti nella sezione Content.  I  PDF erano situati in una struttura di directory e sottodirectory con un particolare significato. Volevo condividere un piccolo esempio d'importazione per due motivi: per ricordarmelo ;-) e perchè magari qualcuno potrebbe capitare nella mia stessa situazione, in fondo il CMS è open source, quindi mi sembra il minimo...&lt;/p&gt;  &lt;p&gt;Supponiamo di avere in Media un Folder denominato &lt;em&gt;Documentazione&lt;/em&gt;, il cui nodo ha ID 8734&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/UmbracoimportazionedifileinMedia_B568/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="164" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/UmbracoimportazionedifileinMedia_B568/image_thumb.png" width="120" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Supponiamo di avere tra i &lt;em&gt;Documet Types&lt;/em&gt;, un &lt;em&gt;NodeType&lt;/em&gt; denominato &lt;em&gt;PaginaMediaPicker, &lt;/em&gt;contenente un Tab denominato &lt;em&gt;content &lt;/em&gt;con due proprietà: &lt;em&gt;title&lt;/em&gt; (&lt;em&gt;Textstring&lt;/em&gt;) e &lt;em&gt;attach (MediaPicker):&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/UmbracoimportazionedifileinMedia_B568/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="110" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/UmbracoimportazionedifileinMedia_B568/image_thumb_1.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Inoltre nella sezione &lt;em&gt;Content, &lt;/em&gt;supponiamo di avere una nodo denominato &lt;em&gt;Importazione&lt;/em&gt; con ID=8806. A questo punto non ci resta che eseguire l'importazione dei dati, per aggiungendo così i documenti PDF nella cartella &lt;em&gt;Documenti PDF&lt;/em&gt; della sezione Media, sotto il nodo &lt;em&gt;Documentazione, &lt;/em&gt;e i rispettivi documenti di Content (istanze di &lt;em&gt;PaginaMediaPicker&lt;/em&gt;) sotto il nodo &lt;em&gt;Importazione&lt;/em&gt;. Possiamo creare una classe per l'importazione dei dati, come ad esempio:&lt;/p&gt;  &lt;p&gt;   &lt;/p&gt;&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:2b16836c-2371-4506-b06e-a71d52bece3e" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt;  1&lt;/span&gt; &lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; ImportMedia
&lt;/span&gt;&lt;span style="color: #008080;"&gt;  2&lt;/span&gt; &lt;span style="color: #000000;"&gt;{
&lt;/span&gt;&lt;span style="color: #008080;"&gt;  3&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; umbraco.BusinessLogic.User _user &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;  4&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;  5&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; ImportMedia(umbraco.BusinessLogic.User user)
&lt;/span&gt;&lt;span style="color: #008080;"&gt;  6&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;  7&lt;/span&gt; &lt;span style="color: #000000;"&gt;        _user &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; user;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;  8&lt;/span&gt; &lt;span style="color: #000000;"&gt;    }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;  9&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 10&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 11&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Crea un nuovo Folder in Media. Se la funzione ha successo, ritorna
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 12&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; l'id del nodo creato
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 13&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 14&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="parentId"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;ID del Parent sotto il quale creare il folder&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 15&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="nome"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;Nome del folder da creare&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 16&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 17&lt;/span&gt; &lt;span style="color: #808080;" /&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; MakeFolderMedia(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; parentId, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; folderName)
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 18&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 19&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;try&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 20&lt;/span&gt; &lt;span style="color: #000000;"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 21&lt;/span&gt; &lt;span style="color: #000000;"&gt;            MediaType folderType &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; MediaType.GetByAlias(&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Folder&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 22&lt;/span&gt; &lt;span style="color: #000000;"&gt;            Media folder &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; Media.MakeNew(folderName, folderType, _user, parentId);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 23&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 24&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; folder.Id;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 25&lt;/span&gt; &lt;span style="color: #000000;"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 26&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;catch&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 27&lt;/span&gt; &lt;span style="color: #000000;"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 28&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #800080;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 29&lt;/span&gt; &lt;span style="color: #000000;"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 30&lt;/span&gt; &lt;span style="color: #000000;"&gt;    }
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 31&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 32&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 33&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Esegue la scansione ricorsiva della directory
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 34&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 35&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="fullDirectoryPath"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;Percorso completo della directory contenente i documenti&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 36&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="searchPattern"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;Pattern di ricerca dei file&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 37&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="documentTypeName"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;Nome del tipo di documento (Document Type) da creare&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 38&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="parentContentId"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;ID del nodo Content a cui aggiungere i nodi di tipo Content&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 39&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="parentMediaId"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;ID del nodo Media a cui aggiungere i nodi documenti caricati&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 40&lt;/span&gt; &lt;span style="color: #808080;" /&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; ScanDirectory(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; fullDirectoryPath, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; searchPattern,
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 41&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; documentTypeName, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; parentContentId, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; parentMediaId)
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 42&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 43&lt;/span&gt; &lt;span style="color: #000000;"&gt;        DirectoryInfo dInfo &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; DirectoryInfo(fullDirectoryPath);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 44&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;foreach&lt;/span&gt;&lt;span style="color: #000000;"&gt; (DirectoryInfo dir &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;in&lt;/span&gt;&lt;span style="color: #000000;"&gt; dInfo.GetDirectories())
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 45&lt;/span&gt; &lt;span style="color: #000000;"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 46&lt;/span&gt; &lt;span style="color: #000000;"&gt;            ScanDirectory(dir.FullName, searchPattern, documentTypeName, parentContentId, parentMediaId);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 47&lt;/span&gt; &lt;span style="color: #000000;"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 48&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 49&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;foreach&lt;/span&gt;&lt;span style="color: #000000;"&gt; (FileInfo file &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;in&lt;/span&gt;&lt;span style="color: #000000;"&gt; dInfo.GetFiles(searchPattern))
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 50&lt;/span&gt; &lt;span style="color: #000000;"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 51&lt;/span&gt; &lt;span style="color: #000000;"&gt;            MediaType fileType &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; MediaType.GetByAlias(&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;File&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 52&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;Crea un oggetto Media, lo inserisce nell'albero sotto il nodo con ID uguale a parentMediaId&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 53&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #000000;"&gt;            Media m &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; Media.MakeNew(file.Name, fileType, _user, parentMediaId);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 54&lt;/span&gt; &lt;span style="color: #000000;"&gt;            m.getProperty(&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;umbracoFile&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;).Value &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; UploadFile(file.FullName,
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 55&lt;/span&gt; &lt;span style="color: #000000;"&gt;                m.getProperty(&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;umbracoFile&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;).Id,
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 56&lt;/span&gt; &lt;span style="color: #000000;"&gt;                m.getProperty(&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;umbracoFile&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;).VersionId);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 57&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 58&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (m.Id &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;)
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 59&lt;/span&gt; &lt;span style="color: #000000;"&gt;                MakeDocument(documentTypeName, file.Name, parentContentId,
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 60&lt;/span&gt; &lt;span style="color: #000000;"&gt;                    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] { &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;title&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;attach&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt; },
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 61&lt;/span&gt; &lt;span style="color: #000000;"&gt;                    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] { file.Name, m.Id.ToString() }
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 62&lt;/span&gt; &lt;span style="color: #000000;"&gt;                );
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 63&lt;/span&gt; &lt;span style="color: #000000;"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 64&lt;/span&gt; &lt;span style="color: #000000;"&gt;    }
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 65&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 66&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 67&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Crea un nuovo documento
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 68&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 69&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="documentTypeName"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;Nome del Document Type da creare&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 70&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="documentName"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;Nome del documento&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 71&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="parentContentId"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;ID del nodo Content a cui aggiungere i nodi di tipo Content&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 72&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="properties"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;Nomi delle proprietà del Document Type che devono essere valorizzate&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 73&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name="values"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;Valori delle proprietà del Document Type &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 74&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 75&lt;/span&gt; &lt;span style="color: #808080;" /&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; MakeDocument(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; documentTypeName, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; documentName, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; parentContentId,
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 76&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] properties, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] values)
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 77&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 78&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 79&lt;/span&gt; &lt;span style="color: #000000;"&gt;        DocumentType dt &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; DocumentType.GetByAlias(documentTypeName);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 80&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 81&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (properties.Length &lt;/span&gt;&lt;span style="color: #000000;"&gt;==&lt;/span&gt;&lt;span style="color: #000000;"&gt; values.Length)
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 82&lt;/span&gt; &lt;span style="color: #000000;"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 83&lt;/span&gt; &lt;span style="color: #000000;"&gt;            Document d &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; Document.MakeNew(documentName, dt, _user, parentContentId);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 84&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 85&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;for&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; index &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;; index &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; properties.Length; index&lt;/span&gt;&lt;span style="color: #000000;"&gt;++&lt;/span&gt;&lt;span style="color: #000000;"&gt;)
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 86&lt;/span&gt; &lt;span style="color: #000000;"&gt;                d.getProperty(properties[index]).Value &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; values[index];
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 87&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 88&lt;/span&gt; &lt;span style="color: #000000;"&gt;            d.Publish(_user);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 89&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 90&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; d.Id;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 91&lt;/span&gt; &lt;span style="color: #000000;"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 92&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;else&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 93&lt;/span&gt; &lt;span style="color: #000000;"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 94&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;throw&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Exception(&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Wrong Data&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 95&lt;/span&gt; &lt;span style="color: #000000;"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 96&lt;/span&gt; &lt;span style="color: #000000;"&gt;    }
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 97&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 98&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 99&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; UploadFile(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; fullFilePath, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; propertyID, System.Guid versionID)
&lt;/span&gt;&lt;span style="color: #008080;"&gt;100&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;101&lt;/span&gt; &lt;span style="color: #000000;"&gt;      &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;Code...&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;102&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #000000;"&gt;    }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;103&lt;/span&gt; &lt;span style="color: #000000;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;


&lt;p&gt;Il sorgente completo della classe ImportMedia è in allegato al post. Il codice sopra, può essere utilizzato, ad esempio in una Web Form, nel seguente modo:&lt;/p&gt;

&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:303f6f51-16ee-46b3-8c0d-fc060b62449e" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt; 1&lt;/span&gt; &lt;span style="color: #000000;"&gt;User user &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; User(&lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 2&lt;/span&gt; &lt;span style="color: #000000;"&gt;ImportMedia import &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; ImportMedia(user);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 3&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 4&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;8734, ID del Parent nella sezione Media&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 5&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; mediaParentId &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; import.MakeFolderMedia(&lt;/span&gt;&lt;span style="color: #800080;"&gt;8734&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Documenti PDF&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 6&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (mediaParentId &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;)
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 7&lt;/span&gt; &lt;span style="color: #000000;"&gt;{
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 8&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;8806, ID del Parent nella sezione Content&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 9&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #000000;"&gt;    import.ScanDirectory(&lt;/span&gt;&lt;span style="color: #800000;"&gt;@"&lt;/span&gt;&lt;span style="color: #800000;"&gt;C:\Percorso_Cartella\PDFs&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;,
&lt;/span&gt;&lt;span style="color: #008080;"&gt;10&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;*.pdf&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;PaginaMediaPicker&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;8806&lt;/span&gt;&lt;span style="color: #000000;"&gt;, mediaParentId);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;11&lt;/span&gt; &lt;span style="color: #000000;"&gt;}
&lt;/span&gt;&lt;span style="color: #008080;"&gt;12&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #0000FF;"&gt;else&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;13&lt;/span&gt; &lt;span style="color: #000000;"&gt;    Response.Write(&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Errore nella creazione del folder in Media&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;Una volta eseguito il codice, nella sezione Media, otterremo:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/UmbracoimportazionedifileinMedia_B568/image_6.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="135" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/UmbracoimportazionedifileinMedia_B568/image_thumb_2.png" width="150" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Mentre nel Content avremo:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/UmbracoimportazionedifileinMedia_B568/image_8.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="111" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/UmbracoimportazionedifileinMedia_B568/image_thumb_3.png" width="144" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Per la corretta esecuzione del codice, in un'applicazione web differente da quella di Umbraco, è necessario impostare correttamente il web.config. &lt;/p&gt;

&lt;p&gt;La versione di Umbraco utilizzata è la 3.0.6.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.pietrolibro.name/sources/ImportMedia.zip" target="_blank"&gt;Codice Completo della classe ImportMedia&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:e46c3fc0-d640-465d-80b1-fb360b227ed1" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/Umbraco" rel="tag"&gt;Umbraco&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Media" rel="tag"&gt;Media&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.ugidotnet.org/PietroLibroBlog/aggbug/94802.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pietro Libro</dc:creator>
            <guid>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/29/umbraco-importazione-di-file-in-media.aspx</guid>
            <pubDate>Sat, 29 Nov 2008 19:17:40 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/PietroLibroBlog/comments/94802.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/29/umbraco-importazione-di-file-in-media.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/PietroLibroBlog/comments/commentRss/94802.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/PietroLibroBlog/services/trackbacks/94802.aspx</trackback:ping>
        </item>
        <item>
            <title>Backup/Restore SMS</title>
            <category>Tools</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/29/backuprestore-sms.aspx</link>
            <description>&lt;p&gt;Avendo acquistato un nuovo Palmare, è sorto il problema di dover trasferire i dati dal vecchio al nuovo dispositivo, tra i quali i messaggi SMS. Ho trovato questa utility, &lt;a href="http://www.pocketpcitalia.com/News/2007/04/SmsImport--backup-e-ripristino/" target="_blank"&gt;SmsImport&lt;/a&gt; veramente interessante. Oltre ad effettuare il backup ed il riprisinto degli SMS, esporta i dati in un file XML (e questo mi suggerisce la possibilità di creare un'applicazione personalizzata che legge da XML ed importa su un databse SQL Server Mobile) ed in più, seguendo il link indicato è possibile scaricare anche i sorgenti (in VC++). La versione è stata aggiornata dallo sviluppatore che ha progettato il tool, al 9 giugno 2008. L'installazione è veramente molto semplice: è sufficiente copiare il file nel dispositivo ed eseguirlo.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:7bca4dba-bd2a-4a4d-9cf6-a223ed5fd086" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/SMS" rel="tag"&gt;SMS&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Pocket%20PC" rel="tag"&gt;Pocket PC&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Import" rel="tag"&gt;Import&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Export" rel="tag"&gt;Export&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.ugidotnet.org/PietroLibroBlog/aggbug/94798.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pietro Libro</dc:creator>
            <guid>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/29/backuprestore-sms.aspx</guid>
            <pubDate>Sat, 29 Nov 2008 12:28:28 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/PietroLibroBlog/comments/94798.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/29/backuprestore-sms.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/PietroLibroBlog/comments/commentRss/94798.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/PietroLibroBlog/services/trackbacks/94798.aspx</trackback:ping>
        </item>
        <item>
            <title>[OT] Nuovo acquisto...</title>
            <category>OT</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/28/ot-nuovo-acquisto.aspx</link>
            <description>&lt;p&gt;Dopo il cedimento strutturale :-) del mio HP &lt;a href="http://h10010.www1.hp.com/wwpc/it/it/ho/WF05a/215348-215348-64929-215381-215381-1822499.html" target="_blank"&gt;HW6915&lt;/a&gt; ho dovuto affrontare l'acquisto di un nuovo Palmare, la scelta è ricaduta (complice anche una buona offerta) su un &lt;a href="http://it.lge.com/products/model/detail/telefonicellulari_ks20.jhtml" target="_blank"&gt;LG KS20&lt;/a&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt; &lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/OTNuovoacquisto_E1BD/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/OTNuovoacquisto_E1BD/image_thumb_1.png" width="172" border="0" /&gt;&lt;/a&gt; &lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/OTNuovoacquisto_E1BD/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/OTNuovoacquisto_E1BD/image_thumb.png" width="172" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Dopo  più di una settimana che l'utilizzo, sono abbastanza soddisfatto dell'acquisto, unico neo: GPS non integrato, ma dato che in due anni di onorato servizio, ho usato il GPS del mio HP solo tre volte, non è un grande problema. Speriamo duri quanto il suo predecessore ;-)&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/PietroLibroBlog/aggbug/94790.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pietro Libro</dc:creator>
            <guid>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/28/ot-nuovo-acquisto.aspx</guid>
            <pubDate>Fri, 28 Nov 2008 15:03:04 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/PietroLibroBlog/comments/94790.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/28/ot-nuovo-acquisto.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/PietroLibroBlog/comments/commentRss/94790.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/PietroLibroBlog/services/trackbacks/94790.aspx</trackback:ping>
        </item>
        <item>
            <title>La crisi colpisce anche Google...</title>
            <category>Varie ed eventuali</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/25/la-crisi-colpisce-anche-google.aspx</link>
            <description>&lt;p&gt;Come descritto &lt;a href="http://www.repubblica.it/2008/11/sezioni/scienza_e_tecnologia/google-8/google-8/google-8.html" target="_blank"&gt;da questo articolo&lt;/a&gt;, neanche il gigante Google è stato risparmiato dall'ondata di crisi internazionale...come andiamo male...&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/PietroLibroBlog/aggbug/94756.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pietro Libro</dc:creator>
            <guid>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/25/la-crisi-colpisce-anche-google.aspx</guid>
            <pubDate>Tue, 25 Nov 2008 16:52:28 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/PietroLibroBlog/comments/94756.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/25/la-crisi-colpisce-anche-google.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/PietroLibroBlog/comments/commentRss/94756.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/PietroLibroBlog/services/trackbacks/94756.aspx</trackback:ping>
        </item>
        <item>
            <title>Image, MemoryStream e file .rdlc</title>
            <category>ASP.NET</category>
            <category>C#</category>
            <category>Reporting</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/25/image-memorystream-e-file-.rdlc.aspx</link>
            <description>&lt;p&gt;Supponiamo di avere un file di Report in formato .rdlc, e di voler stampare una lista di prodotti visualizzando un'immagine prodotta a run-time e memorizzata in un &lt;em&gt;MemoryStream&lt;/em&gt;, piuttosto che utilizzare file d'immagine. Ad esempio, supponiamo di avere nel nostro Database, una tabella denominata Prodotti, contenente 4 colonne:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/ImageStreamefile.rdlc_F64E/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="93" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/ImageStreamefile.rdlc_F64E/image_thumb.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Aggiungiamo al nostro progetto (ad esempio di tipo &lt;em&gt;Web Application&lt;/em&gt;) un DataSet tipizzato (&lt;em&gt;dsProdotti&lt;/em&gt;)  contenente un DataTable &lt;em&gt;Prodotti&lt;/em&gt;, a cui andiamo ad aggiungere una colonna denominata  &lt;em&gt;Immagine,&lt;/em&gt; con proprietà &lt;em&gt;DataType&lt;/em&gt; impostata su &lt;em&gt;System.Byte[]&lt;/em&gt;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/ImageStreamefile.rdlc_F64E/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="193" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/ImageStreamefile.rdlc_F64E/image_thumb_1.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Aggiungiamo un nuovo file di Report (&lt;em&gt;Report1.rdlc&lt;/em&gt;), nel designer del report, dalla toolbox degli strumenti, trasciniamo nella sezione &lt;em&gt;Body&lt;/em&gt;, un item &lt;em&gt;Table&lt;/em&gt; che configuriamo  opportunamente:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/ImageStreamefile.rdlc_F64E/image_6.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="92" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/ImageStreamefile.rdlc_F64E/image_thumb_2.png" width="389" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Come si evince dalla figura, nell'ultima colonna della &lt;em&gt;Table&lt;/em&gt;, è stato aggiunto un controllo Image. Affinchè il tutto funzioni correttamente, è necessario impostare correttamente le proprietà di questo controllo, ovvero: &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;La proprietà &lt;em&gt;Source&lt;/em&gt; deve essere impostata su &lt;em&gt;Database&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;La proprietà &lt;em&gt;MIMEType&lt;/em&gt; deve essere impostata sul tipo di immagine che si vuole visualizzare (&lt;em&gt;images/gif, image/jpeg&lt;/em&gt; etc...) &lt;/li&gt;    &lt;li&gt;La proprietà &lt;em&gt;Value&lt;/em&gt; deve essere impostata sul valore campo contenente lo Stream di byte, nello specifico: &lt;em&gt;=Fields!Immagine.Value&lt;/em&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Agganciato il report ad un opportuno controllo &lt;em&gt;ReportViewer&lt;/em&gt;  non resta che scrivere il codice per recuperare i dati dal Database e popolare un opportuno DataTable, da utilizzare come sorgente dati per il Report:&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:b7f16d89-55a9-4719-80b9-a1fcce2d387f" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt; 1&lt;/span&gt; &lt;span style="color: #000000;"&gt;DsProdotti dsProdotti &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; DsProdotti();
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 2&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 3&lt;/span&gt; &lt;span style="color: #000000;"&gt;dsProdotti.Prodotti.RowChanged &lt;/span&gt;&lt;span style="color: #000000;"&gt;+=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; DataRowChangeEventHandler(Prodotti_RowChanged);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 4&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 5&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; (DsProdottiTableAdapters.ProdottiTableAdapter prodottiAdapter &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; ReportConImmaginiStream.DsProdottiTableAdapters.ProdottiTableAdapter())
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 6&lt;/span&gt; &lt;span style="color: #000000;"&gt;{
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 7&lt;/span&gt; &lt;span style="color: #000000;"&gt;    prodottiAdapter.Fill(dsProdotti.Prodotti);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 8&lt;/span&gt; &lt;span style="color: #000000;"&gt;}
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 9&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;10&lt;/span&gt; &lt;span style="color: #000000;"&gt;ReportViewer1.LocalReport.DataSources.Clear();
&lt;/span&gt;&lt;span style="color: #008080;"&gt;11&lt;/span&gt; &lt;span style="color: #000000;"&gt;ReportViewer1.LocalReport.DataSources.Add(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; Microsoft.Reporting.WebForms.ReportDataSource(&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;DsProdotti_Prodotti&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;, dsProdotti.Prodotti));&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Gestendo  l'evento &lt;em&gt;RowChanged&lt;/em&gt; del DataTable &lt;em&gt;Prodotti, &lt;/em&gt;possiamo popolare il valore del campo &lt;em&gt;Immagine&lt;/em&gt; della riga aggiunta alla collezione del DataTable, con lo stream di byte rappresentante l'immagine che vogliamo visualizzare:&lt;/p&gt;

&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:89f3ea7f-1dd7-4d3b-b8d5-5ff2b4814e35" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt;1&lt;/span&gt; &lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; Prodotti_RowChanged(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;object&lt;/span&gt;&lt;span style="color: #000000;"&gt; sender, DataRowChangeEventArgs e)
&lt;/span&gt;&lt;span style="color: #008080;"&gt;2&lt;/span&gt; &lt;span style="color: #000000;"&gt;{
&lt;/span&gt;&lt;span style="color: #008080;"&gt;3&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (e.Action &lt;/span&gt;&lt;span style="color: #000000;"&gt;==&lt;/span&gt;&lt;span style="color: #000000;"&gt; DataRowAction.Add)
&lt;/span&gt;&lt;span style="color: #008080;"&gt;4&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;5&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;Immagine da Stream&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;6&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #000000;"&gt;         e.Row[&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Immagine&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;] &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; ImageDataRow.ImageDataRowIstance.GetImageArray();
&lt;/span&gt;&lt;span style="color: #008080;"&gt;7&lt;/span&gt; &lt;span style="color: #000000;"&gt;    }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;8&lt;/span&gt; &lt;span style="color: #000000;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;Dove il codice della classe &lt;em&gt;ImageDataRow &lt;/em&gt;è il seguente:&lt;/p&gt;

&lt;p /&gt;

&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ac892a56-29fe-4b89-8e5a-9c8b122e7a8d" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt; 1&lt;/span&gt; &lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; ImageDataRow
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 2&lt;/span&gt; &lt;span style="color: #000000;"&gt;{
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 3&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;byte&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] _imageArray &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 4&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; ImageDataRow _imageDataRowIstance;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 5&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 6&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; ImageDataRow() { }
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 7&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 8&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; ImageDataRow ImageDataRowIstance
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 9&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;10&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;11&lt;/span&gt; &lt;span style="color: #000000;"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;12&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (_imageDataRowIstance &lt;/span&gt;&lt;span style="color: #000000;"&gt;==&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;)
&lt;/span&gt;&lt;span style="color: #008080;"&gt;13&lt;/span&gt; &lt;span style="color: #000000;"&gt;                _imageDataRowIstance &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; ImageDataRow();
&lt;/span&gt;&lt;span style="color: #008080;"&gt;14&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; _imageDataRowIstance;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;15&lt;/span&gt; &lt;span style="color: #000000;"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;16&lt;/span&gt; &lt;span style="color: #000000;"&gt;    }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;17&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;18&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Byte[] GetImageArray()
&lt;/span&gt;&lt;span style="color: #008080;"&gt;19&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;20&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (_imageArray &lt;/span&gt;&lt;span style="color: #000000;"&gt;==&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;)
&lt;/span&gt;&lt;span style="color: #008080;"&gt;21&lt;/span&gt; &lt;span style="color: #000000;"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;22&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; (MemoryStream imgStream &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; MemoryStream())
&lt;/span&gt;&lt;span style="color: #008080;"&gt;23&lt;/span&gt; &lt;span style="color: #000000;"&gt;            {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;24&lt;/span&gt; &lt;span style="color: #000000;"&gt;                System.Drawing.Image img &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; Bitmap(&lt;/span&gt;&lt;span style="color: #800080;"&gt;32&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;32&lt;/span&gt;&lt;span style="color: #000000;"&gt;);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;25&lt;/span&gt; &lt;span style="color: #000000;"&gt;                Graphics gr &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; Graphics.FromImage(img);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;26&lt;/span&gt; &lt;span style="color: #000000;"&gt;                gr.FillRectangle(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; SolidBrush(Color.White), &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;32&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;32&lt;/span&gt;&lt;span style="color: #000000;"&gt;);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;27&lt;/span&gt; &lt;span style="color: #000000;"&gt;                gr.DrawEllipse(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; Pen(Color.Red, &lt;/span&gt;&lt;span style="color: #800080;"&gt;2&lt;/span&gt;&lt;span style="color: #000000;"&gt;), &lt;/span&gt;&lt;span style="color: #800080;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;30&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;30&lt;/span&gt;&lt;span style="color: #000000;"&gt;);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;28&lt;/span&gt; &lt;span style="color: #000000;"&gt;                img.Save(imgStream, System.Drawing.Imaging.ImageFormat.Gif);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;29&lt;/span&gt; &lt;span style="color: #000000;"&gt;                _imageArray &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; imgStream.ToArray();
&lt;/span&gt;&lt;span style="color: #008080;"&gt;30&lt;/span&gt; &lt;span style="color: #000000;"&gt;            }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;31&lt;/span&gt; &lt;span style="color: #000000;"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;32&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; _imageArray;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;33&lt;/span&gt; &lt;span style="color: #000000;"&gt;    }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;34&lt;/span&gt; &lt;span style="color: #000000;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p /&gt;

&lt;p&gt;Dato che nell'esempio viene visualizzata sempre la stessa immagine, per non instanziare ad ogni riga un oggetto &lt;em&gt;MemoryStream&lt;/em&gt; ed eseguire il codice di  disegno, si è scelto di utilizzare un &lt;a href="http://it.wikipedia.org/wiki/Singleton" target="_blank"&gt;Singleton&lt;/a&gt;. Ovviamente, nel caso in cui l'immagine debba cambiare a seconda dei valori contenuti nella riga, il codice dovrà essere ottimizzato opportunamente.&lt;/p&gt;

&lt;p&gt;Il risultato che si otterrà eseguendo il codice, sarà qualcosa del tipo:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/ImageStreamefile.rdlc_F64E/image_8.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="180" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/ImageStreamefile.rdlc_F64E/image_thumb_3.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.pietrolibro.name/sources/ReportConImmaginiStream.zip" target="_blank"&gt;Sorgenti completi del progetto&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/PietroLibroBlog/aggbug/94755.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pietro Libro</dc:creator>
            <guid>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/25/image-memorystream-e-file-.rdlc.aspx</guid>
            <pubDate>Tue, 25 Nov 2008 16:42:48 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/PietroLibroBlog/comments/94755.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/25/image-memorystream-e-file-.rdlc.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/PietroLibroBlog/comments/commentRss/94755.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/PietroLibroBlog/services/trackbacks/94755.aspx</trackback:ping>
        </item>
        <item>
            <title>Se vi annoiate, aiutate la scienza...</title>
            <category>Varie ed eventuali</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/20/se-vi-annoiate-aiutate-la-scienza.aspx</link>
            <description>&lt;p&gt;Leggevo &lt;a href="http://www.repubblica.it/2008/11/sezioni/scienza_e_tecnologia/giochi-scienza/giochi-scienza/giochi-scienza.html?ref=hpspr1" target="_blank"&gt;un&lt;/a&gt; articolo su  una serie di attività e software che potrebbero aiutare la comunità scientifica, distraendosi e utilizzando una parte del tempo libero (e un pò mi viene da ridere...) con semplici videogiochi o con ad esempio, un &lt;a href="http://fold.it/portal/info/science" target="_blank"&gt;software&lt;/a&gt; per la modellazione 3D di proteine, che aiuterebbe la ricerca contro il cancro e l'Aids. Sembra molto interessante, ma  bisogna vedere il numero di persone che aderirà ai vari progetti.&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/PietroLibroBlog/aggbug/94713.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pietro Libro</dc:creator>
            <guid>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/20/se-vi-annoiate-aiutate-la-scienza.aspx</guid>
            <pubDate>Thu, 20 Nov 2008 17:04:34 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/PietroLibroBlog/comments/94713.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/20/se-vi-annoiate-aiutate-la-scienza.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/PietroLibroBlog/comments/commentRss/94713.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/PietroLibroBlog/services/trackbacks/94713.aspx</trackback:ping>
        </item>
        <item>
            <title>Cartelle condivise con Sun VirtualBox</title>
            <category>Virtual Machine</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/16/cartelle-condivise-con-sun-virtualbox.aspx</link>
            <description>&lt;p&gt;Post a titolo di promemoria. Per aggiungere una cartella condivisa in Sun VirtualBox e Microsoft Windows XP Pro come sistema guest, avviata la macchina virtuale, dalla barra dei menu: &lt;em&gt;Dispositivi\Cartelle condivise...&lt;/em&gt; e nella finestra &lt;em&gt;Cartelle condivise&lt;/em&gt;, premere su &lt;em&gt;Add New Shared Folder...&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/CartellecondiviseconSunVirtualBox_F682/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="140" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/CartellecondiviseconSunVirtualBox_F682/image_thumb.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Nella finestra visualizzata, specificare il percorso della cartella sulla macchina host da condividere nel campo &lt;em&gt;Folder Path,&lt;/em&gt;  e specificare un nome (senza spazi) nel campo &lt;em&gt;Folder Name &lt;/em&gt;(ad esempio Temp). A questo punto il gioco è quasi fatto. Nella macchina guest, da riga di comando digitare:&lt;/p&gt;  &lt;p&gt;net use z: \\vboxsrv\Temp&lt;/p&gt;  &lt;p&gt;dove z: è la lettera che si vuole assegnare all'unità di rete mappata sulla cartella condivisa.&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/PietroLibroBlog/aggbug/94661.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pietro Libro</dc:creator>
            <guid>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/16/cartelle-condivise-con-sun-virtualbox.aspx</guid>
            <pubDate>Sun, 16 Nov 2008 16:27:18 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/PietroLibroBlog/comments/94661.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/16/cartelle-condivise-con-sun-virtualbox.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/PietroLibroBlog/comments/commentRss/94661.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/PietroLibroBlog/services/trackbacks/94661.aspx</trackback:ping>
        </item>
        <item>
            <title>[OT] Se il vostro PC &amp;egrave; brutto...</title>
            <category>OT</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/14/ot-se-il-vostro-pc-egrave-brutto.aspx</link>
            <description>&lt;p&gt;...&lt;a href="http://canali.kataweb.it/kataweb-itech/2008/11/13/il-pc-brutto-modificalo/" target="_blank"&gt;qui&lt;/a&gt; potete trovare qualche idea per modificarlo :-)&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/PietroLibroBlog/aggbug/94641.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pietro Libro</dc:creator>
            <guid>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/14/ot-se-il-vostro-pc-egrave-brutto.aspx</guid>
            <pubDate>Fri, 14 Nov 2008 07:34:21 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/PietroLibroBlog/comments/94641.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/14/ot-se-il-vostro-pc-egrave-brutto.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/PietroLibroBlog/comments/commentRss/94641.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/PietroLibroBlog/services/trackbacks/94641.aspx</trackback:ping>
        </item>
        <item>
            <title>WPF: Control Template</title>
            <category>WPF</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/06/wpf-control-template.aspx</link>
            <description>&lt;p&gt;In WPF, l'aspetto grafico di un controllo può essere cambiato utilizzando un C&lt;em&gt;ontrol Template&lt;/em&gt;, ovvero un'insieme di risorse, triggers ed elementi che descrivono il comportamento grafico del controllo. I C&lt;em&gt;ontrol Template&lt;/em&gt; sono utili ogni qual volta si vuole modificare l'aspetto grafico di un controllo, ma allo stesso tempo conservare le funzionalità del controllo stesso. Senza WPF, magari saremmo costretti a costruire un nuovo controllo replicando funzionalità e riscrivendo del codice funzionante. Supponiamo ad esempio di voler cambiare l'aspetto del solito controllo Button, rendendolo &lt;em&gt;fashion&lt;/em&gt; e &lt;em&gt;trendy&lt;/em&gt;. Quello che vogliamo ottenere è qualcosa del tipo:&lt;/p&gt;  &lt;p&gt; &lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/WPFControlTemplate_A54A/image_10.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="182" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/WPFControlTemplate_A54A/image_thumb_4.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/WPFControlTemplate_A54A/image_12.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="182" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/WPFControlTemplate_A54A/image_thumb_5.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Nella seconda figura, è mostrato il comportamento del controllo Button quando il cursorse del mouse è posizionato sopra. &lt;/p&gt;  &lt;p&gt;Uno dei metodi più semplici per cambiare il &lt;em&gt;Template&lt;/em&gt; del controllo è quello di scrivere il codice XAML di descrizione direttamente all'interno del tag &lt;em&gt;Button.Template, &lt;/em&gt; ad esempio:&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:eca17d13-f288-46bd-8b4c-9fac319fb353" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt;1&lt;/span&gt; &lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Button &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;Height&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="16"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Margin&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="51,0,42,12"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="button2"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="Bottom"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Content&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="Bottone"&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;2&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Button.Template   &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;3&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;ControlTemplate&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;4&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Grid&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;5&lt;/span&gt; &lt;span style="color: #000000;"&gt;                &lt;/span&gt;&lt;span style="color: #008000;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color: #008000;"&gt; codice XAML &lt;/span&gt;&lt;span style="color: #008000;"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;6&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Grid&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;                    
&lt;/span&gt;&lt;span style="color: #008080;"&gt;7&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;ControlTemplate&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;8&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Button.Template &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;9&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Button&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;Volendo cambiare l'aspetto di tutti i controlli Button presenti in una Form WPF, andiamo ad utilizzare un oggetto &lt;em&gt;Style,&lt;/em&gt; aggiungendolo  alla collezione delle risorse della Window WPF su cui stiamo lavorando:&lt;/p&gt;

&lt;p&gt;
  &lt;/p&gt;&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:aa5d5659-fe7a-4021-9b3d-cf3ec0dedc25" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt;1&lt;/span&gt; &lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Window.Resources&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;2&lt;/span&gt; &lt;span style="color: #000000;"&gt;   &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Style &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;TargetType&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="Button"&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;3&lt;/span&gt; &lt;span style="color: #000000;"&gt;      &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Setter &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;Property&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="Template"&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;4&lt;/span&gt; &lt;span style="color: #000000;"&gt;      ...
&lt;/span&gt;&lt;span style="color: #008080;"&gt;5&lt;/span&gt; &lt;span style="color: #000000;"&gt;      &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Setter&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;6&lt;/span&gt; &lt;span style="color: #000000;"&gt;   &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;7&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Window.Resources&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;8&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;


&lt;p&gt;Utilizzando una classe &lt;em&gt;Setter&lt;/em&gt;, andiamo ad impostare la proprietà &lt;em&gt;Template&lt;/em&gt; del generico controllo Button, aggiungendo in cascata, una &lt;em&gt;Grid&lt;/em&gt;, un &lt;em&gt;Border&lt;/em&gt; ed un &lt;em&gt;Rectangle. &lt;/em&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;/p&gt;&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:b64c89a7-4774-4dc6-913f-c1fc351dbc8c" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt; 1&lt;/span&gt; &lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Grid&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 2&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Border &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;BorderBrush&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="Aquamarine"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;   BorderThickness&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="1"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="borderButton"&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 3&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Rectangle  &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;Name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="sfondo"&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 4&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Rectangle.Fill&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 5&lt;/span&gt; &lt;span style="color: #000000;"&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;StartPoint&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="0,0"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; EndPoint&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="1,0"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Opacity&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="1"&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 6&lt;/span&gt; &lt;span style="color: #000000;"&gt;                    ...
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 7&lt;/span&gt; &lt;span style="color: #000000;"&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 8&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Rectangle.Fill&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 9&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Rectangle&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;10&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Border&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;11&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;ContentPresenter &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="Center"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="Center"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;  &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;12&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Grid&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;


&lt;p&gt;E' importante spendere qualche parola su &lt;em&gt;ContentPresenter. ContentPresenter&lt;/em&gt; serve a visualizzare il contenuto (in questo caso la semplice stringa "Button") di un &lt;em&gt;ContentControl&lt;/em&gt; come ad esempio &lt;em&gt;Frame&lt;/em&gt;, &lt;em&gt;ToolTip&lt;/em&gt;, &lt;em&gt;Label&lt;/em&gt;, &lt;em&gt;GroupItem,ButtonBase&lt;/em&gt; etc...Se non utilizzassimo &lt;em&gt;ContentPresenter&lt;/em&gt; durante la definizione del &lt;em&gt;Template&lt;/em&gt; del nostro Button, in fase di Rendering, non verrebbe visualizzata nessuna dicitura sul nostro Button, semplicemente perchè non abbiamo detto a WPF dove vogliamo visualizzarla. Possiamo vedere il &lt;em&gt;ContentPresenter&lt;/em&gt; come un segnaposto per indicare dove visualizzare il &lt;em&gt;Content&lt;/em&gt;. Utilizzando una &lt;em&gt;Grid&lt;/em&gt;, come in questo caso, ci assicuriamo che i vari oggetti siano tutti visualizzati in un'unica cella della griglia. Impostando &lt;em&gt;HorizontalAlignment &lt;/em&gt;e &lt;em&gt;VerticalAlignment&lt;/em&gt; su &lt;em&gt;Center, &lt;/em&gt;ci assicuriamo di visualizzare il contenuto del controllo al centro.&lt;/p&gt;

&lt;p&gt;Per cambiare il &lt;em&gt;Background&lt;/em&gt; del Button quando il cursorse del mouse viene posizionato sopra la superficie del controllo, come per &lt;em&gt;Style, &lt;/em&gt;anche per &lt;em&gt;ControlTemplate &lt;/em&gt;abbiamo a disposizione  i &lt;em&gt;Triggers &lt;/em&gt;da sfruttare&lt;em&gt;:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;/p&gt;&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ff7f5467-2e26-4976-9460-4e4472baab91" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt; 1&lt;/span&gt; &lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;ControlTemplate.Triggers&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 2&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Trigger  &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;Property&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="IsMouseOver"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Value&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="true"&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 3&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Setter &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;TargetName&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="sfondo"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Property&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="Fill"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 4&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 5&lt;/span&gt; &lt;span style="color: #000000;"&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;StartPoint&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="0,0"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; EndPoint&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="1,0"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Opacity&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="0.8"&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 6&lt;/span&gt; &lt;span style="color: #000000;"&gt;                ...
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 7&lt;/span&gt; &lt;span style="color: #000000;"&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 8&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 9&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Setter&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;10&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Trigger&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;11&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;ControlTemplate.Triggers&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;


&lt;p&gt;Molto semplicemente, quando ci troviamo con il cursore del mouse sul Button, il &lt;em&gt;Trigger &lt;/em&gt; cambia "il valore" (in verità l'oggetto &lt;em&gt;LinearGradientBrush&lt;/em&gt;) della proprietà &lt;em&gt;Fill&lt;/em&gt; dell'oggetto che ha la proprietà &lt;em&gt;Name&lt;/em&gt; impostata su &lt;em&gt;Sfondo. &lt;/em&gt;Nel procedente codice XAML, questo è &lt;em&gt;Rectangle, &lt;/em&gt;posto all'interno dell'oggetto &lt;em&gt;Border&lt;/em&gt; , di nome &lt;em&gt;borderButton&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Fino  a questo punto, abbiamo raggiunto il nostro primo obiettivo.  Supponiamo ora di voler aggiungere un'ulteriore funzione grafica al nostro controllo. Supponiamo di voler aggiungere un effetto luce diffusa &lt;em&gt;(Glow), &lt;/em&gt;quando ci troviamo ad indicare il button con il mouse (sfruttando in pratica lo stesso &lt;em&gt;Trigger&lt;/em&gt; per &lt;em&gt;IsMouseOver&lt;/em&gt;)&lt;em&gt;. &lt;/em&gt;A questo punto, niente di più facile, dato che l'oggetto &lt;em&gt;Border&lt;/em&gt; espone una proprietà &lt;em&gt;BitmapEffect. S&lt;/em&gt;crivendo del codice XAML simile a questo:&lt;/p&gt;

&lt;p&gt;
  &lt;/p&gt;&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:f1af2575-ec9a-4772-8214-ae6290682f48" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt;1&lt;/span&gt; &lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Setter &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;TargetName&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="borderButton"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Property&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="BitmapEffect"&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;2&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Setter.Value &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;3&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;OuterGlowBitmapEffect &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;GlowColor&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="Yellow"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; GlowSize&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;="10"&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;4&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;5&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Setter&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;


&lt;p&gt;Otterremo l'effetto desiderato:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/WPFControlTemplate_A54A/image_14.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="182" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/WPFControlTemplate_A54A/image_thumb_6.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Personalmente penso che le potenzialità che il WPF offre per personalizzare l'aspetto dei controll sia veramente impressionante. Utilizzando &lt;a href="http://www.microsoft.com/expression/products/Overview.aspx?key=blend" target="_blank"&gt;Expression Blend&lt;/a&gt; si possono sviluppare delle applicazioni davvero accattivanti (soprattutto se si ha un pò di dimestichezza con la grafica :-))&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.pietrolibro.name/sources/ButtonTemplate.zip" target="_blank"&gt;Codice XAML completo della Window WPF&lt;/a&gt;&lt;/p&gt;

&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:cf2f1324-80a6-4636-94b5-3f2f3158efa1" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/WPF" rel="tag"&gt;WPF&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ControlTemplate" rel="tag"&gt;ControlTemplate&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.ugidotnet.org/PietroLibroBlog/aggbug/94536.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pietro Libro</dc:creator>
            <guid>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/06/wpf-control-template.aspx</guid>
            <pubDate>Thu, 06 Nov 2008 12:05:03 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/PietroLibroBlog/comments/94536.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/06/wpf-control-template.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/PietroLibroBlog/comments/commentRss/94536.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/PietroLibroBlog/services/trackbacks/94536.aspx</trackback:ping>
        </item>
        <item>
            <title>Icone gratis</title>
            <category>Varie ed eventuali</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/03/94506.aspx</link>
            <description>&lt;p&gt;Come segnalato da &lt;a href="http://www.repubblica.it/2006/05/gallerie/scienzaetecnologia/icone-artistiche/1.html" target="_blank"&gt;Repubblica&lt;/a&gt;, sul sito &lt;a href="http://sixrevisions.com/" target="_blank"&gt;Six Revisions&lt;/a&gt; è possibile scaricare &lt;a href="http://sixrevisions.com/resources/40-beautiful-free-icon-sets/" target="_blank"&gt;40 Beatiful Free Icon Sets&lt;/a&gt; nei formati png e ico.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4f38da53-52f0-496c-8e7b-9691f7634931" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/Icone" rel="tag"&gt;Icone&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.ugidotnet.org/PietroLibroBlog/aggbug/94506.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pietro Libro</dc:creator>
            <guid>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/03/94506.aspx</guid>
            <pubDate>Mon, 03 Nov 2008 16:45:05 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/PietroLibroBlog/comments/94506.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/03/94506.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/PietroLibroBlog/comments/commentRss/94506.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/PietroLibroBlog/services/trackbacks/94506.aspx</trackback:ping>
        </item>
        <item>
            <title>Da Microsoft Virtual PC a Sun VirtualBox</title>
            <category>Virtual Machine</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/03/94505.aspx</link>
            <description>&lt;p&gt;Avevo la necessità di convertire una macchina virtuale da formato Microsoft Virtual PC a Sun VirtualBox. Per chi avesse avuto lo stesso problema, la soluzione è stata abbastanza semplice: ho eseguito il download di &lt;a target="_blank" href="http://www.vmware.com/download/converter/"&gt;VMware Converter 3.0.3 (Starter Edition)&lt;/a&gt; (previa registrazione),  una volta installato è stato sufficiente lanciare il Wizard avviabile da: &lt;em&gt;File\New\Convert&lt;/em&gt;:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/DaMicrosoftVirtualPCaSunVirtualBox_F6EB/image_2.png"&gt;&lt;img height="172" border="0" width="244" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/DaMicrosoftVirtualPCaSunVirtualBox_F6EB/image_thumb.png" alt="image" style="border: 0px none ;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;e seguire i vari passi:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/DaMicrosoftVirtualPCaSunVirtualBox_F6EB/image_6.png"&gt;&lt;img height="208" border="0" width="244" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/DaMicrosoftVirtualPCaSunVirtualBox_F6EB/image_thumb_2.png" alt="image" style="border: 0px none ;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Impostando come &lt;em&gt;Source Type: Other ed  &lt;/em&gt;in&lt;em&gt; Virtual Machine &lt;/em&gt;il percorso del file con estensione *.vmc. Scegliendo &lt;em&gt;Avanti&lt;/em&gt;, il converter inizierà a leggere le informazioni del file della macchina virtuale di Microsoft Virtural PC  (Ci metterà qualche minuto).&lt;/p&gt;
&lt;p&gt;Proseguendo con il Wizard (dove è possibile ad esempio eseguire la conversione mantenendo la dimensione del disco fissa oppure ridimensionandolo per salvare spazio disco), al momento di scegliere il tipo di destinazione (&lt;em&gt;Select the destination type&lt;/em&gt;)&lt;em&gt;, &lt;/em&gt;ho selezionato &lt;em&gt;Other Virtual Machine&lt;/em&gt;, e nella schermata successiva, ho specificato il nome della Virtual Machine  e ho selezionato &lt;em&gt;Workstation 6.x, VMware Fusion 1.x, Player 2.x, ACE 2.x. &lt;/em&gt;Andando avanti si possono scegliere altre opzioni secondo delle proprie esigenze. Secondo della dimensione del file della Virtual Machine di cui si vuol fare la conversione, la procedura richiederà un pò di tempo (nel mio caso per una file di circa 19GB sono stati necessari più di 30 minuti).&lt;/p&gt;
&lt;p&gt;A questo punto non resta che creare una nuova macchina virtuale su Sun VirtualBox seguendo il Wizard. Al momento della scelta dell'Hard-disk virtuale, scegliere &lt;em&gt;esistente:&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/DaMicrosoftVirtualPCaSunVirtualBox_F6EB/image_12.png"&gt;&lt;img height="153" border="0" width="244" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/DaMicrosoftVirtualPCaSunVirtualBox_F6EB/image_thumb_5.png" alt="image" style="border: 0px none ;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;nel &lt;em&gt;Gestore dei dischi virtuali,&lt;/em&gt; fare click su &lt;em&gt;aggiungi&lt;/em&gt; e scegliere il percorso del file con estensione *.vmdk creato utilizzando il VMWare converter. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/DaMicrosoftVirtualPCaSunVirtualBox_F6EB/image_14.png"&gt;&lt;img height="191" border="0" width="244" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/PietroLibroBlog/WindowsLiveWriter/DaMicrosoftVirtualPCaSunVirtualBox_F6EB/image_thumb_6.png" alt="image" style="border: 0px none ;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Una volta selezionato il file, è sufficiente continuare fino alla fine. Una volta terminata la procedura guidata è possibile impostare le varie opzioni per la macchina virtuale appena creata (attivare l'accesso a periferiche USB, impostare le schede di rete, cartelle condivise etc...).&lt;/p&gt;
&lt;p&gt;Al momento, l'unico problema che ho incontrato dopo la conversione è un leggero sfarfallio del contenuto della finestra della macchina virtuale durante il passaggio della modalità a Schermo intero e viceversa o durante il ridimensionamento della finestra del sistema guest, tutto sommato nulla di particolare. Non resta che testare il comportamento durante le sessioni di lavoro.&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/PietroLibroBlog/aggbug/94505.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pietro Libro</dc:creator>
            <guid>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/03/94505.aspx</guid>
            <pubDate>Mon, 03 Nov 2008 16:30:13 GMT</pubDate>
            <wfw:comment>http://blogs.ugidotnet.org/PietroLibroBlog/comments/94505.aspx</wfw:comment>
            <comments>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/03/94505.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/PietroLibroBlog/comments/commentRss/94505.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/PietroLibroBlog/services/trackbacks/94505.aspx</trackback:ping>
        </item>
        <item>
            <title>FTP: Download/Upload di un file con ProgressBar</title>
            <category>C#</category>
            <link>http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/11/02/94493.aspx</link>
            <description>&lt;p&gt;Post nato da &lt;a href="http://www.dotnethell.it/forum/messages.aspx?ThreadID=26321" target="_blank"&gt;discussione&lt;/a&gt; su forum. Supponiamo di voler creare un client ftp (applicazione Windows Form) per il download/upload di file, utilizzando un controllo ProgressBar per visualizzare lo stato di avanzamento dell'operazione. Grazie alle classi messe a disposizione del Framework .Net, il codice per il download di un file remoto, potrebbe essere del tipo:&lt;/p&gt;  &lt;p&gt;   &lt;/p&gt;&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:afb0aa11-311c-403d-92a3-f09eef2d4745" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt; 1&lt;/span&gt; &lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;Connessione con l'host&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 2&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #000000;"&gt;Connect(remotePathFile);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 3&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 4&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;Imposta il tipo di richiesta&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 5&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #000000;"&gt;_conn.Method &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; WebRequestMethods.Ftp.DownloadFile;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 6&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 7&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;Ottiene la risposta&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 8&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #000000;"&gt;_resp &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; (FtpWebResponse)(_conn.GetResponse());
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 9&lt;/span&gt; &lt;span style="color: #000000;"&gt;System.IO.Stream _respStream &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; _resp.GetResponseStream();
&lt;/span&gt;&lt;span style="color: #008080;"&gt;10&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;11&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (ContinueProcess(_resp.StatusDescription))
&lt;/span&gt;&lt;span style="color: #008080;"&gt;12&lt;/span&gt; &lt;span style="color: #000000;"&gt;{
&lt;/span&gt;&lt;span style="color: #008080;"&gt;13&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;Apre il file locale per la scrittura
&lt;/span&gt;&lt;span style="color: #008080;"&gt;14&lt;/span&gt; &lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;....&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;15&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;16&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;try&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;17&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;18&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;Recupera la dimensione del file come numero di bytes&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;19&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #000000;"&gt;        Int64 totalBytes &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; GetFileSize(remotePathFile);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;20&lt;/span&gt; &lt;span style="color: #000000;"&gt;        Int64 totalBytesRead &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;21&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;22&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (downloadFileStarted &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;) downloadFileStarted(totalBytes);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;23&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;24&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;byte&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] buf &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;byte&lt;/span&gt;&lt;span style="color: #000000;"&gt;[&lt;/span&gt;&lt;span style="color: #800080;"&gt;1024&lt;/span&gt;&lt;span style="color: #000000;"&gt;];
&lt;/span&gt;&lt;span style="color: #008080;"&gt;25&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;26&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; bytesRead &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; _respStream.Read(buf, &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, buf.Length);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;27&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;28&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;while&lt;/span&gt;&lt;span style="color: #000000;"&gt; (bytesRead &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;)
&lt;/span&gt;&lt;span style="color: #008080;"&gt;29&lt;/span&gt; &lt;span style="color: #000000;"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;30&lt;/span&gt; &lt;span style="color: #000000;"&gt;            totalBytesRead &lt;/span&gt;&lt;span style="color: #000000;"&gt;+=&lt;/span&gt;&lt;span style="color: #000000;"&gt; bytesRead;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;31&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;32&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (downloadFileProgress &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;) downloadFileProgress(totalBytes, totalBytesRead);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;33&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;34&lt;/span&gt; &lt;span style="color: #000000;"&gt;            fileStream.Write(buf, &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, bytesRead);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;35&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;36&lt;/span&gt; &lt;span style="color: #000000;"&gt;            bytesRead &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; _respStream.Read(buf, &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, buf.Length);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;37&lt;/span&gt; &lt;span style="color: #000000;"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;38&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;39&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (downloadFileCompleted &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;) downloadFileCompleted();
&lt;/span&gt;&lt;span style="color: #008080;"&gt;40&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;41&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;true&lt;/span&gt;&lt;span style="color: #000000;"&gt;;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;42&lt;/span&gt; &lt;span style="color: #000000;"&gt;    }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;43&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;catch&lt;/span&gt;&lt;span style="color: #000000;"&gt; (WebException ex)
&lt;/span&gt;&lt;span style="color: #008080;"&gt;44&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;45&lt;/span&gt; &lt;span style="color: #000000;"&gt;      &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;.....&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;46&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #000000;"&gt;    }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;47&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;finally&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;48&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;49&lt;/span&gt; &lt;span style="color: #000000;"&gt;        fileStream.Close();
&lt;/span&gt;&lt;span style="color: #008080;"&gt;50&lt;/span&gt; &lt;span style="color: #000000;"&gt;        _respStream.Close();
&lt;/span&gt;&lt;span style="color: #008080;"&gt;51&lt;/span&gt; &lt;span style="color: #000000;"&gt;    }
&lt;/span&gt;&lt;span style="color: #008080;"&gt;52&lt;/span&gt; &lt;span style="color: #000000;"&gt;}
&lt;/span&gt;&lt;span style="color: #008080;"&gt;53&lt;/span&gt; &lt;span style="color: #000000;" /&gt;&lt;span style="color: #0000FF;"&gt;else&lt;/span&gt;&lt;span style="color: #000000;"&gt; ...
&lt;/span&gt;&lt;span style="color: #008080;"&gt;54&lt;/span&gt; &lt;span style="color: #000000;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;


&lt;p&gt;mentre il codice per eseguire l'upload, potrebbe essere del tipo:&lt;/p&gt;

&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:2e5b8fa0-a9dd-4acb-ae32-afd838d7deb3" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080;"&gt; 1&lt;/span&gt; &lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (Connect(remoteFilePath))
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 2&lt;/span&gt; &lt;span style="color: #000000;"&gt;{
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 3&lt;/span&gt; &lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;try&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 4&lt;/span&gt; &lt;span style="color: #000000;"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 5&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;Connected&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 6&lt;/span&gt; &lt;span style="color: #008000;" /&gt;&lt;span style="color: #000000;"&gt;        _conn.Method &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; WebRequestMethods.Ftp.UploadFile;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 7&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 8&lt;/span&gt; &lt;span style="color: #000000;"&gt;        FileInfo file &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; FileInfo(localFilePath);
&lt;/span&gt;&lt;span style="color: #008080;"&gt; 9&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;10&lt;/span&gt; &lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (file.Length &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;)
&lt;/span&gt;&lt;span style="color: #008080;"&gt;11&lt;/span&gt; &lt;span style="color: #000000;"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080;"&gt;12&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (uploadFileStarted &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;) uploadFileStarted(file.Length);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;13&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;14&lt;/span&gt; &lt;span style="color: #000000;"&gt;            Stream strUpload &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; _conn.GetRequestStream();
&lt;/span&gt;&lt;span style="color: #008080;"&gt;15&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;16&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; bytesRead &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;17&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; totalBytesRead &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;18&lt;/span&gt; &lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;byte&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] fileBytes &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;byte&lt;/span&gt;&lt;span style="color: #000000;"&gt;[&lt;/span&gt;&lt;span style="color: #800080;"&gt;1024&lt;/span&gt;&lt;span style="color: #000000;"&gt;];
&lt;/span&gt;&lt;span style="color: #008080;"&gt;19&lt;/span&gt; &lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #008080;"&gt;20&lt;/span&gt; &lt;span style="color: #000000;"&gt;            FileStream strLocalFile &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; FileStream(localFilePath, FileMode.Open);
&lt;/span&gt;&lt;span style="color: #008080;"&gt;21&lt;/span&gt; &lt;span style="color: #000000;"&gt;            bytesRead &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; strLocalFile.Read(fileBytes, &lt;/spa