in web mvc project.
i have following function trying make async save many files , bit slow. need add list of tasks , await all:
var fs = new filesaver(); property.floorplanpath = fs.savefile(propertyrentalform.floorplanfile, "~/uploads/properties/floorplans"); property.floorplan2path = fs.savefile(propertyrentalform.floorplan2file, "~/uploads/properties/floorplans"); property.epcpath = fs.savefile(propertyrentalform.epcfile, "~/uploads/properties/epc"); public string savefile(httppostedfilebase file, string uploadpath) { if (file == null || file.contentlength <= 0) return ""; var filename1 = path.getfilename(file.filename); if (filename1 == null) return ""; // clean file name filename1 = string.format("{0}{1}", path.getfilenamewithoutextension(filename1).getaliastitle(), path.getextension(filename1)); var path = path.combine(httpcontext.current.server.mappath(uploadpath), filename1); file.saveas(path); return filename1; }
if have single disk save files there no meaning make async. because have limited disk i/o. can use queue mechanism , can check queue status asynchronously...
Comments
Post a Comment