by
0
7
2,970
1
Top 1% !
Popular
Famous
Easy-to-find
Specified
Tuned
OpenSource
Popularity: 4779th place
.NETFramework4.5
Architecturex86_64
Extension.cs
InputName0ByteArray
InputName1FilePath
InputType0byte[]
InputType1string
LanguageCSharp
MethodNameToFile
OutputTypeFileInfo

Easy Write Bytes to File

This snnipet write (or overwrite) a ByteArray to file on specific path and return a FileInfo of the created file
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/770807/Easy-Write-Bytes-to-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 FileInfo ToFile(this byte[] ByteArray, string FilePath) { if (File.Exists(FilePath)) { File.Delete(FilePath); } System.IO.FileStream fs = new System.IO.FileStream(FilePath, System.IO.FileMode.Create, System.IO.FileAccess.Write); fs.Write(ByteArray, 0, ByteArray.Length); fs.Close(); return new FileInfo(System.IO.Path.GetFileName(FilePath)); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus