示例#1
0
        /// <summary>
        /// 根据文件相对路径获取到文件流
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static byte[] GetFileBytes(string filePath)
        {
            var fileService = new File.WebReference.FileService();
            var b           = fileService.GetFileBase64String(filePath);

            return(b == ""? new byte[0]: Convert.FromBase64String(b));
        }
示例#2
0
        private static string Upload(Stream stream, string fileName)
        {
            if (stream.Length == 0)
            {
                throw new CustomException("文件大小为零");
            }
            var data = new byte[stream.Length];

            stream.Read(data, 0, data.Length);
            var fileService = new File.WebReference.FileService()
            {
                Url = FileWeb + "/FileService.asmx"
            };
            var fileNameOnServer = fileService.Upload(data, fileName);

            return(fileNameOnServer);
        }