Scheduler for UWP | ComponentOne
Features / Import and Export / Importing Data
In This Topic
    Importing Data
    In This Topic

    There are two ways through which you can load data into your application. Either you can allow users to select what will be imported, or you can handle it silently.

    To handle importing data and allow user to select the file to be loaded into the application, use the following code:

    Copy Code
    // opens Open File (system defined) dialog and allows end-user to select what file should be imported
    C1Scheduler.ImportCommand.Execute(null, sched1);

    To handle importing data silently, use the following code:

    To import data from a local XML or iCal file in the application folder, place the following code in a Load Button click, Page Navigated To or Loaded event.

    Copy Code
    // Import XML from app local folder
    var folder = Windows.Storage.ApplicationData.Current.LocalFolder;
        var file = await folder.GetFileAsync("appointments.xml");
        IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
        await sched1.DataStorage.ImportAsync(stream.AsStreamForRead(), C1.C1Schedule.FileFormatEnum.XML);
    catch { }