Exemplo n.º 1
0
        /// <summary>
        /// 文件上传
        /// </summary>
        /// <param name="request"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public FileTransferMessageCheck TransferUpFile(FileTransferMessage request)
        {
            FileTransferMessageCheck FTMC = new FileTransferMessageCheck();
            string MainPath = GetClass.GetPathConfig(ref FTMC.reMessage);

            if (string.IsNullOrEmpty(MainPath))
            {
                FTMC.reMessage = "Null XML";
                FTMC.isBool    = false;
                return(FTMC);
            }
            else
            {
                if (!File.Exists(request.FileName))
                {
                    FTMC.isBool = GetClass.FileSave(request.FileName, request.FileData, ref FTMC.reMessage);
                    return(FTMC);
                }
                else
                {
                    FileInfo info = new FileInfo(request.FileName);
                    if (info.Length > fileLimitLength)
                    {
                        FTMC.reMessage = "File Is ALive";
                        FTMC.isBool    = false;
                        return(FTMC);
                    }
                    else
                    {
                        FTMC.isBool = GetClass.FileSave(request.FileName, request.FileData, ref FTMC.reMessage);
                        return(FTMC);
                    }
                }
            }
        }
Exemplo n.º 2
0
        long fileLimitLength = 3000;//文件限制
        /// <summary>
        /// 检查文件是否可传输
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public FileTransferMessageCheck TransferChkFile(FileTransferMessageCheck request)
        {
            string MainPath = GetClass.GetPathConfig(ref request.reMessage);

            if (string.IsNullOrEmpty(MainPath))
            {
                request.isBool = false;
                return(request);
            }
            else
            {
                if (request.FileName.Contains(".jpg") && request.FileLength > fileLimitLength)
                {
                    string DirTimes     = MainPath + "\\" + request.TimePath;
                    string DirNames     = DirTimes + "\\" + request.NamePath;
                    string FileNamePath = DirNames + "\\" + request.FileName;
                    if (!Directory.Exists(DirTimes))
                    {
                        request.reMessage = FileNamePath;
                        request.NamePath  = DirNames;
                        request.TimePath  = DirTimes;
                        request.isBool    = true;
                        Directory.CreateDirectory(DirTimes);
                    }
                    if (!Directory.Exists(DirNames))
                    {
                        request.reMessage = FileNamePath;
                        request.NamePath  = DirNames;
                        request.TimePath  = DirTimes;
                        request.isBool    = true;
                        Directory.CreateDirectory(DirNames);
                    }
                    if (!File.Exists(FileNamePath))
                    {
                        request.reMessage = FileNamePath;
                        request.NamePath  = DirNames;
                        request.TimePath  = DirTimes;
                        request.isBool    = true;
                        return(request);
                    }
                    else
                    {
                        FileInfo info = new FileInfo(FileNamePath);
                        if (info.Length > fileLimitLength)
                        {
                            request.reMessage = "File Is ALive";
                            request.NamePath  = DirNames;
                            request.TimePath  = DirTimes;
                            request.isBool    = false;
                            return(request);
                        }
                        else
                        {
                            request.reMessage = FileNamePath;
                            request.NamePath  = DirNames;
                            request.TimePath  = DirTimes;
                            request.isBool    = true;
                            return(request);
                        }
                    }
                }
                else
                {
                    request.reMessage = "Picture Type Or Length Limit";
                    request.isBool    = false;
                    return(request);
                }
            }
        }