C #: get the file version information and the deletion of read-only files

xiaoxiao2021-03-06  59

Author: David Eulerdate: 2004/11 / 16Email: de_euler-david@yahoo.com.cn

If you have any questions, please contact me :) Get the version of the file: fileversionInfo myfileversioninfo1 = fileversioninfo.getversionInfo ("D: //test.dll"); TextBox1.text = "version number:" myfileversioninfo1.fileversion;

Change the file properties, delete read-only files: The following will copy the E: /TEST.TXT file to D: /TMP/Test.txt, but d: /tmp/test.txt already exists. //File.copy ;True; use to copy files // When DestinationFile already exists, you cannot copy file file1 to the target file, so remove the Destination file first, file.delete () method cannot be deleted Read-only file, // therefore, if the file attribute is read-only ("readonly" in the Attributes property), then reset the file attribute to Normal, then delete: string file1 = "E: // Test .txt "; String destinationFile =" d: //tmp/test.txt "; if (fileinfo fi = new fileinfo (decimutes.tostring) {fileInfo fi = new fileinfo (decibutes.tostring (). Indexof ("Readonly")! = - 1) fi.attributes = fileAttributes.Normal; file.delete (DestinationFile);} file.copy (file1, destinationfile, true);

转载请注明原文地址:https://www.9cbs.com/read-90931.html

New Post(0)