Re: File deletion from server folder



Alexey Smirnov wrote:
On Apr 5, 2:38 am, James Page <f...@xxxxxxxxxxxxxx> wrote:
Alexey Smirnov wrote:
On Apr 5, 1:02 am, James Page <JamesP...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Thanks Alexey
Could you perhaps show me the context of your code say in a buttons click
event?
I think it can be similar to the following:
void DeleteButton_Click(object sender, EventArgs e)
{
//someone deletes their entry on the database
//let us assume that you have a userid UID
//find picture name
string sql1="SELECT picture FROM users WHERE userid=" +
UID.ToString();
....
string filename = ... // result of sql-query
File.Delete(Server.MapPath(filename));
//delete user record
string sql2="DELETE FROM users WHERE userid=" + UID.ToString();
....
}
File is from the System.IO
Thanks again Alexey

Do you have a VB.net example?- Hide quoted text -

- Show quoted text -

There is no big difference between C# and VB

Sub DeleteButton_Click(ByVal sender As Object, ByVal e As EventArgs)

Dim filename As String = ...
File.Delete(Server.MapPath(filename))

End Sub

http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx

:-)

Thanks again Alexey

If I get into problems I'll re-post
.