ChiakiYu.Common.Web.WebHelper.GetPhysicalFilePath C# (CSharp) Method

GetPhysicalFilePath() public static method

获取物理文件路径
public static GetPhysicalFilePath ( string filePath ) : string
filePath string /// /// filePath支持以下格式: /// /// ~/abc/ /// c:\abc\ /// \\192.168.0.1\abc\ /// /// ///
return string
        public static string GetPhysicalFilePath(string filePath)
        {
            string calculatedFilePath = null;

            // Make sure it isn't a drive reference like "c:\blah" or a UNC name like "\\machine\share"
            if ((filePath.IndexOf(":\\") != -1) || (filePath.IndexOf("\\\\") != -1))
                calculatedFilePath = filePath;
            else
            {
                if (HostingEnvironment.IsHosted)
                {
                    calculatedFilePath = HostingEnvironment.MapPath(filePath);
                }
                else
                {
                    filePath = filePath.Replace('/', Path.DirectorySeparatorChar).Replace("~", "");
                    calculatedFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filePath);
                }
            }
            return calculatedFilePath;
        }