Hi,
Using SaveFileDialog (not RadSaveFileDialog) in Telerik apps is broken.
I'm using the [STAThread] attribute on my Program.cs.
When running my app in Debug mode , I get the following exception when ShowDialog is called :
à System.Windows.Forms.FileDialog.RunDialog(IntPtr hWndOwner)
à System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
à NDC.WinUI.Helpers.WinDbFileHelper.<ExportDB>d__4.MoveNext()
When trying the same in Release mode, my app simply freezes and does nothing.
Here is my code :
public static async Task<bool> ExportDB(string dbPath)
{
try
{
if(File.Exists(dbPath))
{
List<DriveInfo> usbDrives = DriveInfo.GetDrives().Where(drive => drive.DriveType == DriveType.Removable && drive.IsReady).ToList();
using(SaveFileDialog sfd = new SaveFileDialog()
{
DefaultExt = NdcConstants.SqLiteExtension.ExtensionFilter,
InitialDirectory = usbDrives.Count != 0 ? usbDrives[0].RootDirectory.FullName : Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
Filter = NdcConstants.SqLiteExtension.FriendlyName,
FileName = Path.GetFileName(dbPath),
RestoreDirectory = true
})
{
if(sfd.ShowDialog() == DialogResult.OK)
{
if(File.Exists(sfd.FileName))
{
File.Delete(sfd.FileName);
}
await SqlFileBackup.ProcessOnlineBackup(dbPath, sfd.FileName);
return true;
}
}
}
return false;
}
catch(Exception ex)
{
Interaction.Error(ex);
return false;
}
}
Which is call like this : await WinDbFileHelper.ExportDB(settings.LocalDatabaseFullPath)
Base .Net SDK Dialog class should be able to work even if called inside a Telerik app/form.
The ticket title should be SaveFileDialog, my apologies