How can i assign Property System.IO.FileInfo.Length
?
It is read only!
FileInfo.Length is used to get the size of a file, the only way to change a file size is by modifying it's content
If you want to set a file's size programmatically you would have to write something to it. The simplest way would probably be to just fill it with zeros.
public void writeEmptyFile(string path, int size)
{
using(FileStream fs = new FileStream(path, System.IO.FileMode.Append, System.IO.FileAccess.ReadWrite))
{
fs.Write(new byte[size], 0, size);
}
}
This method will either A) write a new file containing null-bytes (the file will have the specified size), or B) if the file path
already exists it will append the specified amount of null-bytes to that file, increasing it's size.