protected void asyncImage_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) {
string[] path;
string filename;
string uId = Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString();
try {
if (asyncImage.HasFile) {
path = asyncImage.PostedFile.FileName.Split(new char[] { '\\' });
filename = uId + "_" + path[path.Length - 1];
asyncImage.SaveAs(Server.MapPath("~/temp/"+filename));
hdnUploadedImage.Value = filename;
Session["uploadedImage"] = filename;
Session["Imagepath"] =path; //it is showing me 92e95d97-0575-42f6-b08b-8c81a72d0b07_System.string[] insted of 92e95d97-0575-42f6-b08b-8c81a72d0b07_3d-windows-8-wallpaper-ocean--sunset-30--1600-x-1200-jpeg-1280x1024jpg
}
} catch (Exception ex) {
ShowMessageAlert(ex.Message);
} finally {
//nothing to do
uPanelDataEntry.Update();
}
}

Guest UserPosted Jun 16, 2011, 8:48 AM
string[] path = filename.Split('\\')
Then the path array will contain the following elements:
path[0] = "C:"
path[1] = "Windows"
path[2] = "foo.txt"
To retrieve the array, you'll have to cast the session variable as a string array as Dorababu explained.
If you want to store the path as one string instead of an array then you can just do this:
Session["path"] = asyncImage.PostedFile.FileName;
Dorababu MekaPosted Jun 16, 2011, 8:39 AM
And in the next page, you can retrieve it like this.
Guest UserPosted Jun 20, 2011, 8:46 AM
private static string[] GetFiles(string sourceFolder, string filters, System.IO.SearchOption searchOption)
{
return filters.Split('|').SelectMany(filter => System.IO.Directory.GetFiles(sourceFolder, filter, searchOption)).ToArray();
}
sagar BhosalePosted Jun 17, 2011, 10:04 PM
so my problem is that how to delete that images according that userid
using foreach loop how i collect images according to userid then matching that userid how i will delete images pleaz help me i very trouble to find out solution
my code is
how to write code axccording to above logic pleas help me sir thanks again for reply
protected void Session_End(object sender, EventArgs e) {
string uId = Membership.GetUser(Context.User.Identity.Name).ProviderUserKey.ToString();
string filepath;
//string[] filename;
filepath = System.Web.Hosting.HostingEnvironment.MapPath("~/temp/");
DirectoryInfo di = new DirectoryInfo(filepath);
FileInfo[] files = di.GetFiles("*.jpg", SearchOption.TopDirectoryOnly);
foreach (FileInfo item in files)
{
if (item.Name.ToString() == "sagar_abc.jpg")
{
if (File.Exists(Path.Combine(filepath, item.Name)))
File.Delete(Path.Combine(filepath, item.Name));
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////
i hava one doubt that
1)
FileInfo[] files = di.GetFiles("*.jpg", SearchOption.TopDirectoryOnly); //suppose user added any extenstion image i.e. .png & .gif so how i will write FileInfo[] files
2)
if (item.Name.ToString() == "sagar_abc.jpg") // suppose in my project temp folder suppose sagar_abc.jpg & sagar_cbd.gif images present
so my problem is that how i collect that images according userid i.e. sagar then that images deleted
Sir can we write this in your code
imagepathcollection = allimagepath.Where(img => img.StartWith(userId)); //you will get all images which starts with the userid specified.
can we used search string method to collrect images according to initial name of string i.e. sagar ?
pleas reply me
Guest UserPosted Jun 17, 2011, 11:15 AM
sagar BhosalePosted Jun 17, 2011, 10:08 AM
so my problem is that how to delete that images according that userid
using foreach loop how i collect images according to userid then matching that userid how i will delete images pleaz help me i very trouble to find out solution
i want to my code in above format how can i do this pleaz help me
my code is global.asax.cs
protected void Session_End(object sender, EventArgs e) {
string userId = Session["UserId"].ToString();
string path;
//string ImagePath =Session["Imagepath"].ToString();
path = System.Web.Hosting.HostingEnvironment.MapPath("~/temp/" + userId + "_");
FileInfo filepath = new FileInfo(path);
if (filepath.Exists) {
File.Delete(filepath.FullName);
}
}
Guest UserPosted Jun 17, 2011, 10:06 AM
sagar BhosalePosted Jun 17, 2011, 9:04 AM
so my problem is that how to delete that images according that userid
using foreach loop how i collect images according to userid then matching that userid how i will delete images pleaz help me i very trouble to find out solution
i want to my code in above format how can i do this pleaz help me
my code is global.asax.cs
protected void Session_End(object sender, EventArgs e) {
sagar BhosalePosted Jun 17, 2011, 9:04 AM
so my problem is that how to delete that images according that userid
using foreach loop how i collect images according to userid then matching that userid how i will delete images pleaz help me i very trouble to find out solution
i want to my code in above format how can i do this pleaz help me
my code is global.asax.cs
protected void Session_End(object sender, EventArgs e) {
sagar BhosalePosted Jun 16, 2011, 9:27 PM