﻿using System;

namespace SGLibrary.Extend
{
    public class ExApp
    {
        /// <summary>
        /// 判断是WinApp还是WebApp
        /// </summary>
        public static Boolean IsWinFormApp()
        {
            return ExIO.GetFormatDir(AppDomain.CurrentDomain.BaseDirectory)
                == ExIO.GetFormatDir(System.Windows.Forms.Application.StartupPath);
        }

        //System.Windows.Forms.Application.StartupPath
        //WinFormApp: 当前应用程序启动的磁盘目录
        //WebFormApp_IIS: c:\windows\system32\inetsrv
        //WebFormApp_DevServer: C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0

        //System.Windows.Forms.Application.ExecutablePath
        //WinFormApp: 当前应用程序的全名，包含路径、扩展名
        //WebFormApp_IIS: c:\windows\system32\inetsrv\w3wp.exe
        //WebFormApp_DevServer: C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\WebDev.WebServer20.exe

        //AppDomain.CurrentDomain.BaseDirectory
        //结束有"\\"
        //WinFormApp: 当前应用程序启动的磁盘目录
        //WebFormApp_IIS: 当前网站所在的磁盘目录
        //WebFormApp_DevServer: 当前网站所在的磁盘目录

        //Environment.CurrentDirectory
        //WinFormApp: 系统当前目录，程序无指定则默认为当前应用程序启动的磁盘目录，随着OpenFileDialog等文件操作而改变，对快捷方式可以通过“起始位置”指定初始值
        //WebFormApp_IIS: c:\windows\system32\inetsrv
        //WebFormApp_DevServer: C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0

        //AppDomain.CurrentDomain.RelativeSearchPath
        //WinFormApp: null
        //WebFormApp_IIS: 当前网站所在的磁盘目录\bin
        //WebFormApp_DevServer: 当前网站所在的磁盘目录\bin
    }
}
