I am creating a file using:
File.WriteAllText(FILEPATHNAME, "SOME VALUE");
When creating a file, is it possible to specify a version programmatically? So that if someone were to use FileVersionInfo object they would get the version I specified?
To create a file in a 'C' program following syntax is used, FILE *fp; fp = fopen ("file_name", "mode"); In the above syntax, the file is a data structure which is defined in the standard library. fopen is a standard function which is used to open a file.
The fopen function creates the file if it does not exist.
The Create() method of the File class is used to create files in C#. The File. Create() method takes a fully specified path as a parameter and creates a file at the specified location; if any such file already exists at the given location, it is overwritten.
The FileVersionInfo is a binary resource that can be stored in an executable file. However, you are writing a text file and those files cannot contain binary resources. Asking for the version (as defined by FileVersionInfo) of a text file does make sense
Unfortunately, it is not possible. Version information is an embedded resource attached to a file and only binary files can have embedded resources.
See the remarks section of FileVersionInfo Class for more information.
As an alternate approach, you can create an additional text file for each text file you are writing containing the version information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With