Prompted to overwrite the file

Last post 02-01-2011, 10:30 AM by Eric. 1 replies.
Sort Posts: Previous Next
  •  02-01-2011, 1:47 AM 65981

    Prompted to overwrite the file

    Please tell me how I can implement a request to overwrite existing file?
    Filed under:
  •  02-01-2011, 10:30 AM 65990 in reply to 65981

    Re: Prompted to overwrite the file

    Dear SergeyC,
     
    Please refer to the following code:

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
        void InsertMsg(string msg)
        {
            ListBoxEvents.Items.Insert(0, msg);
            ListBoxEvents.SelectedIndex = 0;
        }
        void Uploader_FileUploaded(object sender, UploaderEventArgs args)
        {
             InsertMsg("File uploaded! " + args.FileName + ", " + args.FileSize + " bytes.");
            //Copys the uploaded file to a new location.
             String targetpath = "c:\\temp\\" + args.FileName;
             if (System.IO.File.Exists(targetpath))
             {
                 //you can add prompt code here
                 System.IO.File.Delete(targetpath);
             }
             args.MoveTo("c:\\temp\\"+args.FileName);
        }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Selecting multiple files for upload</title>
        <link rel="stylesheet" href="demo.css" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
            <div class="content">                  
                <CuteWebUI:Uploader runat="server" ID="Uploader1" InsertText="Upload Multiple Files (Max 10M)"
                    MultipleFilesUpload="true" OnFileUploaded="Uploader_FileUploaded">
                    <ValidateOption MaxSizeKB="10240" />
                </CuteWebUI:Uploader>
                <div>            
                    <asp:ListBox runat="server" ID="ListBoxEvents" Width="400"></asp:ListBox>
                </div>
            </div>
        </form>
    </body>
    </html>

    Thank you for asking
View as RSS news feed in XML