Esempio n. 1
0
 public I3SharpZipFileInfo(string aFileName, string aFullName, long aFileSize, I3SZFileInfoMode aMode)
 {
     fileName = aFileName;
     fullName = aFullName;
     fileSize = aFileSize;
     mode     = aMode;
 }
Esempio n. 2
0
        /// <summary>
        /// 构造函数,根据完整文件名生成适应于ZipEntry的文件名
        /// </summary>
        /// <param name="aFileName"></param>
        /// <param name="aBasePath"></param>
        /// <param name="isDirctory"></param>
        public I3SharpZipFileInfo(string aFullName, string aBaseDir, bool isDirctory, I3SZFileInfoMode aMode)
        {
            string aFileName;

            if (string.IsNullOrEmpty(aBaseDir))
            {
                aFileName = Path.GetFileName(aFullName);
            }
            else
            {
                aBaseDir  = I3DirectoryUtil.CheckDirctoryLastChar(aBaseDir);
                aFileName = aFullName.Replace(aBaseDir, string.Empty);
            }

            if (isDirctory)
            {
                aFileName = I3DirectoryUtil.CheckDirctoryLastChar(aFileName);
            }

            aFileName = aFileName.Replace(@"\", "/");

            if (isDirctory)
            {
                fileName = aFileName;
                fullName = aFullName;
                fileSize = 0;
                mode     = aMode;
            }
            else
            {
                using (FileStream fileStream = new FileStream(aFullName, FileMode.Open, FileAccess.Read))
                {
                    fileName = aFileName;
                    fullName = aFullName;
                    fileSize = fileStream.Length;
                    mode     = aMode;
                }
            }
        }