Reputation: 1410
Good day! I have some file called "*.dat" with text into it. So, i try to create attribure "Version" ,but don't know how. Can i do it via c#? Can you write some examples?
Such like this?
File.SetAttributes(path, attributes);
Thank you!
Upvotes: 0
Views: 11137
Reputation: 23793
reating "custom" file attributes is not allowed.
You can only set one of the FileAttributes .
Example:
File.SetAttributes(@"C:\myfile.txt", FileAttributes.Hidden);
Upvotes: 0
Reputation: 3813
The attributes you can change here are the NTFS attributes. Details here: http://msdn.microsoft.com/en-us/library/system.io.fileattributes%28v=vs.110%29.aspx
Version is a resource embedded in an executable file. A similar question was asked here: How do I set the version information for an existing .exe, .dll?
Upvotes: 0
Reputation: 34489
You're probably struggling because you can't add arbitrary information into a file. There are a known set of attributes you can change using the FileAttribute properties
What you would normally do is provide some information at the start of your file, typically called the file header. This then allows a custom reading implementation to read out the version, without having to read the rest of the file. This is quite standard practise with all the files you're used to, for example a WAV audio file:
Upvotes: 3
Reputation: 74250
You can't. The only values allowed are from the list here
Upvotes: 3