Re: Programatically setting TempDirectory ?

  •  07-26-2011, 4:31 AM

    Re: Programatically setting TempDirectory ?

    Hi paulg,
     
    You can set TempDirectory by the code below
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    4.   
    5. <script runat="server">  
    6.     protected override void OnInit(EventArgs e)  
    7.     {  
    8.         base.OnInit(e);  
    9.         Uploader1.TempDirectory = "~/temp/u2/";  
    10.     }  
    11.   
    12.     void InsertMsg(string msg)  
    13.     {  
    14.         ListBoxEvents.Items.Insert(0, msg);  
    15.         ListBoxEvents.SelectedIndex = 0;  
    16.     }  
    17.     void Uploader_FileUploaded(object sender, UploaderEventArgs args)  
    18.     {  
    19.         Uploader uploader = (Uploader)sender;  
    20.         InsertMsg("File uploaded! " + args.FileName + ", " + args.FileSize + " bytes.");  
    21.   
    22.         //Copys the uploaded file to a new location.  
    23.         //args.CopyTo("c:\\temp\\"+args.FileName);  
    24.         //You can also open the uploaded file's data stream.  
    25.         //System.IO.Stream data = args.OpenStream();  
    26.     }       
    27. </script>  
    28.   
    29. <html xmlns="http://www.w3.org/1999/xhtml">  
    30. <head runat="server">  
    31.     <title>Simple Upload</title>  
    32.     <link rel="stylesheet" href="demo.css" type="text/css" />  
    33. </head>  
    34. <body>  
    35.     <form id="form1" runat="server">  
    36.         <div class="content">  
    37.             <h2>  
    38.                 Simple Upload (Customizing the UI)  
    39.             </h2>  
    40.             <p>  
    41.                 A sample demonstrating how to customize the look and feel of file upload controls.  
    42.                 (Maximum file size: 10M).  
    43.             </p>  
    44.             <asp:Image runat="server" ID="Uploader1Insert" AlternateText="Upload File" ImageUrl="~/sampleimages/upload.png" />  
    45.             <asp:Panel runat="server" ID="Uploader1Progress" BorderColor="Orange" BorderStyle="dashed"  
    46.                 BorderWidth="2" Style="padding-right: 4px; padding-left: 4px; padding-bottom: 4px;  
    47.                 padding-top: 4px">  
    48.                 <asp:Label ID="Uploader1ProgressText" runat="server" ForeColor="Firebrick"></asp:Label>  
    49.             </asp:Panel>  
    50.             <asp:Image runat="server" ID="Uploader1Cancel" AlternateText="Cancel" ImageUrl="~/sampleimages/cancel_button.gif" />  
    51.             <CuteWebUI:Uploader runat="server" ID="Uploader1" InsertButtonID='Uploader1Insert'  
    52.                 ProgressCtrlID='Uploader1Progress' ProgressTextID='Uploader1ProgressText' CancelButtonID='Uploader1Cancel'  
    53.                 OnFileUploaded="Uploader_FileUploaded">  
    54.                 <ValidateOption MaxSizeKB="10240" />  
    55.             </CuteWebUI:Uploader>  
    56.             <br />  
    57.             <br />  
    58.             <div>  
    59.                 Server Trace:  
    60.                 <br>  
    61.                 <br>  
    62.                 <asp:ListBox runat="server" ID="ListBoxEvents" Width="400"></asp:ListBox>  
    63.             </div>  
    64.         </div>  
    65.     </form>  
    66. </body>  
    67. </html> 
     
    Hope it helps.
     
    Regards,
    Jeff
View Complete Thread