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!
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!
You can't. The only values allowed are from the list here
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:
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?
reating "custom" file attributes is not allowed.
You can only set one of the FileAttributes .
Example:
File.SetAttributes(@"C:\myfile.txt", FileAttributes.Hidden);