> You should save the file on the server first as a tempoirary file, and
> then present the information that the file already exists. If yes, replace
> the existing file - if no delete the temp one.
>
> Regards
>
> John Timney (MVP)
>
http://www.johntimney.com >
http://www.johntimney.com/blog >
>
> "Bart" <b@s> wrote in message
> news:%23A5jOsUoHHA.1000@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> i use the FileUpload control but if the uploaded file already exists, i
>> want let the choice between overwriting or not the existing file.
>> Therefore i use a radiobuttonlist with 'yes' and 'no'.
>>
>> I get no error, but if i take 'yes', the new file which overwrites the
>> existing one is empty. I think it's because of the postabck caused by the
>> radiobuttonlist, so the Fileupload control looses the chosen file. I put
>> the FileUpLoad1.FileName in a hiddenfield in order to get it back after
>> the 2nd postback, but no succes.
>>
>> Thanks for help
>> Bart
>>
>> Here my code:
>> aspx:
>> <asp:FileUpLoad id="FileUpLoad1" runat="server" /><br /><br />
>> <asp:Button id="Button1" Text="Opladen" runat="server" /><br /><br
>> />
>> <asp:Label id="Label1" runat="server" />
>> <asp:HiddenField ID="HiddenField1" runat="server" />
>> <asp:RadioButtonList ID="RadioButtonList1" runat="server"
>> Visible=false AutoPostBack=true>
>> <asp:ListItem Value="ja" Text="ja" ></asp:ListItem>
>> <asp:ListItem Value="nee" Text="nee" ></asp:ListItem>
>> </asp:RadioButtonList>
>>
>> code-behind:
>>
>> Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles Button1.Click
>> If FileUpLoad1.HasFile Then
>> If File.Exists(Server.MapPath("~/uploaddir/" &
>> FileUpLoad1.FileName)) Then
>> HiddenField1.Value = FileUpLoad1.FileName
>> Label1.Text = FileUpLoad1.FileName & " is already on
>> server. Overwrite?"
>> RadioButtonList1.Visible = True
>> Else
>> Label1.Visible = False
>> FileUpLoad1.SaveAs(Server.MapPath("~/uploaddir/" &
>> FileUpLoad1.FileName))
>> End If
>> End If
>> End Sub
>>
>> Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As
>> Object, ByVal e As System.EventArgs) Handles
>> RadioButtonList1.SelectedIndexChanged
>> If RadioButtonList1.SelectedValue = "yes" Then
>> Label1.Visible = False
>> FileUpLoad1.SaveAs(Server.MapPath("~/uploaddir/" &
>> HiddenField1.Value))
>> Else
>> RadioButtonList1.Visible = False
>> Label1.Visible = False
>> End If
>> End Sub
>> End Class
>>
>>
>>
>
>