Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/Dashboard/CS/DashboardMainDemo/Data/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/Dashboard/CS/DashboardMainDemo/Data/DataLoader.cs

using System.Collections.Generic;
using System.Data;
using System;
using DevExpress.Utils;

namespace DashboardMainDemo {
    public static class DataLoader {
        static string GetRelativePath(string name) {
            name = "Data\\" + name;
            string path = System.Windows.Forms.Application.StartupPath;
            string s = "\\";
            for(int i = 0; i <= 10; i++) {
                if(System.IO.File.Exists(path + s + name))
                    return (path + s + name);
                else
                    s += "..\\";
            }
            path = Environment.CurrentDirectory;
            s = "\\";
            for(int i = 0; i <= 10; i++) {
                if(System.IO.File.Exists(path + s + name))
                    return (path + s + name);
                else
                    s += "..\\";
            }
            return "";
        }
        static DataSet LoadData(string fileName) {
            string path = GetRelativePath(string.Format("{0}.xml", fileName));
            DataSet ds = new DataSet();
            ds.ReadXml(path, XmlReadMode.ReadSchema);
            return ds;
        }
        public static DataSet LoadSales() {
            return LoadData("DashboardSales");
        }
        public static DataSet LoadEmployees() {
            return LoadData("DashboardEmployeesAndDepartments");
        }
        public static DataSet LoadCustomerSupport() {
            return LoadData("DashboardCustomerSupport");
        }
    }
}