Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we specify a file version when creating a file in C#?

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?

like image 234
user1202434 Avatar asked Aug 22 '12 13:08

user1202434


People also ask

How do you create a new file in C?

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.

Does fopen create a new file in C?

The fopen function creates the file if it does not exist.

How do you create a file in C sharp?

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.


2 Answers

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

like image 76
Martin Liversage Avatar answered Nov 09 '22 23:11

Martin Liversage


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.

like image 32
M. Mennan Kara Avatar answered Nov 10 '22 01:11

M. Mennan Kara