示例#1
0
        public virtual VFileInfo GetFileInfo(IServiceContainer services, string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }
            VFileInfo info = new VFileInfo();

            try
            {
                if (fileName.IndexOf(":") < 0)
                {
                    fileName    = System.IO.Path.Combine(System.Environment.CurrentDirectory, fileName);
                    info        = new VFileInfo(new System.IO.FileInfo(fileName));
                    info.Format = WriterUtils.GetFormat(fileName).ToString();
                }
                else
                {
                    Uri uri = new Uri(fileName);
                    if (uri.Scheme == Uri.UriSchemeFile)
                    {
                        info        = new VFileInfo(new System.IO.FileInfo(uri.LocalPath));
                        info.Format = WriterUtils.GetFormat(uri.LocalPath).ToString();
                    }
                    else
                    {
                        info.Exists   = true;
                        info.Format   = FileFormat.XML.ToString();
                        info.Name     = fileName;
                        info.FullPath = fileName;
                        info.BasePath = WriterUtils.GetBaseURL(fileName);
                    }
                }
            }
            catch
            {
                // 出现错误,认为文件不存在
                info.Exists   = false;
                info.Name     = fileName;
                info.FullPath = fileName;
            }
            return(info);
        }