c# - Getting the file size from StreamWriter -
using (var writer = file.createtext(fullfilepath)) { file.write(filecontent); } given above code, can file size known streamwriter?
yes, can, try following
long length = writer.basestream.length;//will give unexpected output if autoflush false , write has been called before note: writer.basestream.length property can return unexpected results since streamwriter doesn't write immediately. caches expected output need autoflush = true
writer.autoflush = true; or writer.flush(); long length = writer.basestream.length;//will give expected output
Comments
Post a Comment