-4

With below code I am generating a zip file name = result.zip. Is this possible to prevent re-naming this file. User should not be able to re-name this file.

string startPath = @"C:\TEMP\PS";//folder to add
string zipPath = @"C:\TEMP\result.zip";//ZIP file path
ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest, true);
Hans Kesting
  • 38,117
  • 9
  • 79
  • 111
user584018
  • 10,186
  • 15
  • 74
  • 160

1 Answers1

2

The only thing that springs to mind is if you make the file read only after you create it. If the user has enough permissions, they could rename it only by removing the read only attribute. They can still rename it, but it would be harder for them. If you have to write to it again later you would need your code to first remove the read only attribute. Maybe even make it hidden. There isn't an ideal solution that I am aware of.

C# make file read/write from readonly

Steve
  • 1,823
  • 1
  • 13
  • 14