Beispiel #1
0
        // 文件上传完毕时操作
        void fileUpload_FileUploadCompleted(object sender, FileUploadCompletedEventArgs args)
        {
            string fileName = "";

            OuterServiceFO fsFO = new OuterServiceFO();

            try
            {
                FileInfo fi = new FileInfo(args.FilePath);
                string   completedFileName = UploadFileInfo.GetAppCompletedFileName(fileInfo.FileName, DateTime.Now);
                string   targetFile        = Path.Combine(fi.Directory.FullName, completedFileName);


                string relateId = HttpContext.Current.Request.QueryString["RelateId"];
                string src      = HttpContext.Current.Request.QueryString["Src"];

                long fileSize = fi.Length;

                fileName = fsFO.AddLocalFile(fi.FullName, completedFileName, relateId, "", "", src, true);

                ctx.Response.ContentEncoding = Encoding.Unicode;
                ctx.Response.Write(fileName + "_" + fileSize.ToString());
                ctx.Response.Flush();
            }
            catch (Exception exp)
            {
                if (fileName != "")
                {
                    fsFO.DelFiles(fileName, string.Format("Upload页面错误,{0}", exp.Message).Substring(0, 200));
                    FileInfo file = new FileInfo(args.FilePath);
                    file.Delete();
                }

                ctx.Response.ContentEncoding = Encoding.Unicode;
                ctx.Response.Write("error:" + exp.Message);
                ctx.Response.Flush();
            }


            this.WriteLog("Upload End");
        }
Beispiel #2
0
 // 生成临时文件名(文件未上传完毕, "T" + UserId + 文件名 + 客户端最后修改时间, 若文件在客户端有任何修改则不能实现断点上传功能.)
 public static string GetAppTemporaryFileName(UploadFileInfo uploadFileInfo)
 {
     //return GetAppTemporaryFileName(uploadFileInfo.UserId, uploadFileInfo.FileName, uploadFileInfo.LastClientWriteDateTime.ToFileTime().ToString());
     return(GetAppTemporaryFileName(uploadFileInfo.UserId, uploadFileInfo.FileName, uploadFileInfo.FileLength));
 }
Beispiel #3
0
 /// <summary>
 /// 构建未上传文件信息
 /// </summary>
 /// <param name="userId">文件userId</param>
 /// <param name="fileName">文件名</param>
 /// <param name="lastClientWriteFileTime">客户端最后修改时间(FileTime)</param>
 ///public UploadFileInfo(string userId, string fileName, string lastClientWriteFileTime)
 public UploadFileInfo(string userId, string fileName, long fileLength)
 {
     this._fileName = fileName.Replace(',', ',');
     //Init(UploadFileInfo.GetAppTemporaryFileName(userId, fileName, lastClientWriteFileTime));
     Init(UploadFileInfo.GetAppTemporaryFileName(userId, fileName, fileLength));
 }
Beispiel #4
0
 /// <summary>
 /// 构建已上传文件信息
 /// </summary>
 /// <param name="fileName">文件名</param>
 /// <param name="uploadDateTime">上传时间</param>
 public UploadFileInfo(string fileName, DateTime uploadDateTime)
 {
     this._fileName = fileName.Replace(',', ',');
     Init(UploadFileInfo.GetAppCompletedFileName(fileName, uploadDateTime));
 }