by
51 6
1
6
370
1
Top 5% !
Popular
Tagged
Specified
Refined
OpenSource

Published on:

FrameworkUWP
InputName0filename
InputType0string
Languagecsharp
LicenseMIT_X11
MethodNameGetFileSize
OutputTypeTask<ulong>

What is the size of this file?

Tells me the size of the given file using the basic properties of UWP StorageFile.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/4361253/What-is-the-size-of-this-file??startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public static async Task<ulong> GetFileSize(this string filename) { StorageFile file = await GetFile(filename); if (file == null) return 0; try { BasicProperties fileSize = await file.GetBasicPropertiesAsync(); return fileSize.Size; } catch (Exception e) { s_log.ErrorFormat("Cannot read file {0} due to {1}", filename, e.Message); return 0; } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus