public UpFileResult UpLoadFile(UpFile filedata)
 {
     UpFileResult result = new UpFileResult();
     string path = System.AppDomain.CurrentDomain.BaseDirectory + @"\service\";
     if (!Directory.Exists(path))
     {
         Directory.CreateDirectory(path);
     }
     byte[] buffer = new byte[filedata.FileSize];
     FileStream fs = new FileStream(path + filedata.FileName, FileMode.Create, FileAccess.Write);
     int count = 0;
     while ((count = filedata.FileStream.Read(buffer, 0, buffer.Length)) > 0)
     {
         fs.Write(buffer, 0, count);
     }
     //清空缓冲区
     fs.Flush();
     //关闭流
     fs.Close();
     result.IsSuccess = true;
     return result;
 }
예제 #2
0
        public UpFileResult UpLoadFile(UpFile filedata)
        {
            UpFileResult result = new UpFileResult();
            string       path   = System.AppDomain.CurrentDomain.BaseDirectory + @"\service\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            byte[]     buffer = new byte[filedata.FileSize];
            FileStream fs     = new FileStream(path + filedata.FileName, FileMode.Create, FileAccess.Write);
            int        count  = 0;

            while ((count = filedata.FileStream.Read(buffer, 0, buffer.Length)) > 0)
            {
                fs.Write(buffer, 0, count);
            }
            //清空缓冲区
            fs.Flush();
            //关闭流
            fs.Close();
            result.IsSuccess = true;
            return(result);
        }