5

对于OpenFileDialogSafeFileNamesFileNames
有什么区别?

为什么SafeFileNamessafe

4

2 回答 2

6

The answer is right there on the pages you linked. The "safe" filename doesn't include the path. Just the filename and the extension. The regular filename includes the full path.

The SafeFileName is safe because it doesn't expose the directory structure of your computer.

于 2012-07-16T17:39:13.687 回答
3

The main difference is that FileNames requires FileIOPermissionAccess.AllAccess security permissions, since it's returning path information about the system into the process. A user running with very low trust permission sets will trigger security exceptions if you try to access FileNames, as the path information is not available.

With SafeFileNames, the property "should be accessible to code running with limited trust." It's "safe" in terms of being able to be used with limited rights.

于 2012-07-16T17:41:31.060 回答