Beispiel #1
0
        /// <summary>
        /// 直接向文件夹中传文件
        /// </summary>
        /// <param name="motherPathName"></param>
        /// <param name="data"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        //public string UpLoad_Mfile(string motherPathName, byte[] data, string fileName)
        //{
        //    string r = "无效操作";

        //    string iniPath = System.AppDomain.CurrentDomain.BaseDirectory + "/HR_Models.ini";
        //    Ini ini = new Ini(iniPath);
        //    string tempPath = ini.ReadValue("root", "UserRootPath") + PublicClassRule.JieXiMuLu(motherPathName);//解析目录

        //    string path = string.Format(@"{0}\{1}", tempPath/*,DateTime.Now.ToString("yyyyMMddHHmmss")*/, fileName);
        //    bool r2 = FileHelper.ByteToFile(data, path);
        //    if (r2)
        //    {
        //        r = "上传成功";

        //    }
        //    else
        //    {
        //        r = "上传失败";
        //    }

        //    return r;
        //}



        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="motherPathName"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public byte[] DownLoad_Mfile(string motherPathName, string fileName)
        {
            string r = "无效操作";

            try
            {
                string iniPath  = System.AppDomain.CurrentDomain.BaseDirectory + "/HR_Models.ini";
                Ini    ini      = new Ini(iniPath);
                string tempPath = ini.ReadValue("root", "UserRootPath") + PublicClassRule.JieXiMuLu(motherPathName);//解析目录
                //已经有路径了,再查一下该文件夹是否正在使用中
                //拼接文件完整路径
                string fullfilename = string.Format("{0}{1}", tempPath, fileName);
                return(FileHelper.FileToByte(fullfilename));
            }
            catch (Exception)
            {
                r = "文件夹名称解析异常";
            }

            return(null);
        }