Esempio n. 1
0
    protected void ASPxImageGallery1_CustomCallback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
    {
        string[] parts   = e.Parameter.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
        string   command = parts[0];

        if (command.Equals("REMOVE", StringComparison.InvariantCultureIgnoreCase))
        {
            int    index            = Convert.ToInt32(parts[1]);
            string sourceFolderPath = Server.MapPath(ASPxImageGallery1.SettingsFolder.ImageSourceFolder);
            string fileName         = Path.GetFileName(ASPxImageGallery1.Items[index].ImageUrl);

            int paramCharIndex = fileName.IndexOf("?");

            if (paramCharIndex != -1)
            {
                fileName = fileName.Remove(paramCharIndex);
            }

            File.Delete(Path.Combine(sourceFolderPath, fileName));
            ASPxImageGallery1.UpdateImageCacheFolder();
        }
        else if (command.Equals("REFRESH", StringComparison.InvariantCultureIgnoreCase))
        {
            ASPxImageGallery1.UpdateImageCacheFolder();
        }
    }
    protected void ASPxImageGallery1_CustomCallback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
    {
        string[] parts   = e.Parameter.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
        string   command = parts[0];

        if (command.Equals("REMOVE", StringComparison.InvariantCultureIgnoreCase))
        {
            File.Delete(string.Format(Server.MapPath(ASPxImageGallery1.ImageUrlFormatString), GetImageFileNameById(parts[1])));
            AccessDataSource1.DeleteParameters["ID"].DefaultValue = parts[1];
            AccessDataSource1.Delete();
            ASPxImageGallery1.UpdateImageCacheFolder();
        }
        else if (command.Equals("REFRESH", StringComparison.InvariantCultureIgnoreCase))
        {
            ASPxImageGallery1.UpdateImageCacheFolder();
        }
    }
Esempio n. 3
0
    protected void ASPxImageGallery1_CustomCallback(object sender, CallbackEventArgsBase e)
    {
        imageIndicies.Clear();
        string fileName;

        foreach (var item in ASPxHiddenField1)
        {
            string   cacheFolderPath = Server.MapPath(ASPxImageGallery1.SettingsFolder.ImageCacheFolder);
            string[] cachedImages    = Directory.GetFiles(cacheFolderPath, "*" + item.Key + "*", SearchOption.AllDirectories);
            for (int i = 0; i < cachedImages.Length; i++)
            {
                //Deleting image files in a running online sample is not allowed, uncomment this line to test deleting on your local machine
                //File.Delete(cachedImages[i]);
            }
            fileName = Server.MapPath(Path.Combine(ASPxImageGallery1.SettingsFolder.ImageSourceFolder, item.Key));
            if (File.Exists(fileName))
            {
                //Deleting image files in a running online sample is not allowed, uncomment this line to test deleting on your local machine
                //File.Delete(fileName);
            }
        }
        ASPxImageGallery1.UpdateImageCacheFolder();
    }