This is a migrated thread and some comments may be shown as answers.

Change initial directory of open image dialog

1 Answer 155 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Marian
Top achievements
Rank 2
Iron
Iron
Iron
Marian asked on 19 Nov 2020, 09:38 AM

Hello,

is it possible to change initial directory of open image dialog in image editor? I tried to set current directory by Directory.SetCurrentDirectory, but it seems it uses always some last opened directory.

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Nov 2020, 12:39 PM

Hello, Marian,    

Please refer to the below code snippet which demonstrates a custom RadImageEditor control that replaces the initial directory when trying to open in image in RadImageEditor
        public class CustomImageEditor : RadImageEditor 
        {
            public override string ThemeClassName  
            { 
                get 
                { 
                    return typeof(RadImageEditor).FullName;  
                }
            }

            protected override RadImageEditorElement CreateImageEditorElement()
            {
                return new CustomImageEditorElement();
            }
        }

        public class CustomImageEditorElement : RadImageEditorElement
        {
            protected override Type ThemeEffectiveType     
            { 
                get    
                { 
                    return typeof(RadImageEditorElement);     
                }
            }
            
            public override void OpenImage()
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.InitialDirectory = @"C:\Projects";
                dialog.RestoreDirectory = true;
                dialog.FilterIndex = 1;
                dialog.Filter = "All image files|*.bmp; *.gif; *.ico; *.jpg; *.jpeg; *.jpe; *.jif; *.jfif; *.jfi; *.png; *.tiff; *.tif|Bitmap images|*.bmp|GIF images|*.gif|Icon images|*.ico|JPEG images|*.jpg; *.jpeg; *.jpe; *.jif; *.jfif; *.jfi|PNG images|*.png|TIFF images|*.tiff; *.tif";

                if (DialogResult.OK == dialog.ShowDialog())
                {
                    this.OpenImage(dialog.FileName);
                }
            }
        }
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ImageEditor
Asked by
Marian
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or