Last post Nov 25, 2014 11:44 AM by Jesper Petersen
Nov 24, 2014 08:26 AM|Jesper Petersen|LINK
this is so that when I need to upload a right an image to an article so it must delete the old image
and it must be clear in the folder where the image is located,
string Tid = DateTime.Now.Ticks.ToString();
string unikID = Guid.NewGuid().ToString();
string url = "../../img/bimg/";
cmd.CommandText = "SELECT img FROM aktiviteter WHERE Id = @id;";
SqlDataReader reader = cmd.ExecuteReader();
File.Delete(url + reader["img"] + ".png");
problem is that I need to find the image in the column in the database where the entity who should delete the picture.
this is how my upload works fine but it's just to take it away from the old folder so it is no more.
Nov 24, 2014 12:18 PM|gerrylowry|LINK
@Jesper Peter... welcome to forums.asp.net
sorry, for me, your question lacks clarity.
to take it away
take what away?
old folder so it is no more.
what is no more? if you mean the folder, there is likely no need to remove the folder; after all, you are about to put the replacement image in your folder.
Nov 24, 2014 04:17 PM|Jesper Petersen|LINK
You can see what i mena on here;
Sorry for i suck to english..
Nov 24, 2014 05:31 PM|gerrylowry|LINK
@Jesper Peter... no need to apologize for your English, it will improve as you gain more experience; unfortunately for most people on this planet, English is the
lingua franca; luckily for me, English is my mother tongue.
FWIW, you may find this helpful: https://translate.google.com/
Jesper, i viewed your SO link; when posting the same question to more than one forum, imho, it's appropriate to mention that at each site; likewise, when you have solved your issue, it's courteous to mention that at each forum, otherwise, your peers at forum
A may still be trying to help you when your solution is already at forum B.
Jesper, at this point, are both your client browser and your web server on the same machine? i.e., your test/development machine?
your solution may be relative paths ... check this out: http://msdn.microsoft.com/en-us/library/ms178116(v=vs.100).aspx "ASP.NET Web Site Paths"
Nov 25, 2014 04:57 AM|Eileen ni - MSFT|LINK
Thanks for your post.
you would need to know where the "old/current" picture is stored, and IF the upload succeeds, simply delete the old picture using this here:
stream.Read(buffer, 0, buffer.Length);
There's a similar thread:
#Deleting existing image after uploading new image!
Hope this can be helpful.
Nov 25, 2014 11:44 AM|Jesper Petersen|LINK
mistake was that none of the pictures that I tried to delete in the folder and therefore give it these errors as I got.
Thanks for y will help me :)