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

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -