Click here to Skip to main content
15,891,902 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi guys, how do I make a dummy file/(s) in vb.net.
I just want the basic, fill a file with data and save it to a specific size e.g. 1024.5 mb.
How would I do that?
Posted
Comments
Sergey Alexandrovich Kryukov 6-Mar-15 10:27am    
Dummy of maybe temporary? Why dummy?
—SA
Kschuler 6-Mar-15 11:34am    
If the people posting solutions aren't posting what you are looking for, you should click Improve Question and add more information that specifies what you are trying to do.

VB
Dim fs As New FileStream("c:\tmp\huge_dummy_file", FileMode.CreateNew)
fs.Seek(2048L * 1024 * 1024, SeekOrigin.Begin)
fs.WriteByte(0)
fs.Close()


Ref : Creating a Huge Dummy File in a Matter of Seconds in C#
 
Share this answer
 
Answers at Create File With Certain File Size[^].
Quote:
This will give you a 1024 byte file:
VB
Dim enc As New System.Text.ASCIIEncoding
Dim filestuff As String
filestuff = New String(Chr(0), 1024)
File.WriteAllBytes("C:\Users\Me\textsizer.txt", enc.GetBytes(filestuff))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900