0

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!

1
  • What is your goal? See the version in file properties? Or just save the metadata anywhere? Either way, you should probably consider a simpler alternative like embedding the data inside the file - it will be much more resilient to actions like web download, email attachment and moving between different file systems (many USBs are FAT32, for example) Commented Jun 2, 2014 at 12:50

4 Answers 4

3

You can't. The only values allowed are from the list here

Sign up to request clarification or add additional context in comments.

2 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
Links to MSDN are very likely one of the most stable out there, so I wouldn't lose my sleep over it.
3

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:

enter image description here

Comments

0

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?

Comments

0

reating "custom" file attributes is not allowed.

You can only set one of the FileAttributes .

Example:

File.SetAttributes(@"C:\myfile.txt", FileAttributes.Hidden);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.