12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System.Configuration;
- using System.IO;
- namespace PDF_Master.Properties {
-
-
-
-
-
-
-
- internal sealed partial class Settings {
-
- public Settings() {
-
-
-
-
- this.SettingsSaving += this.SettingsSavingEventHandler;
-
- }
-
- private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
-
- }
-
- private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
-
- try
- {
-
- var filepath = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath;
- if (isFileLocked(filepath))
- {
- e.Cancel = true;
- }
- }
- catch
- {
- }
- }
-
-
-
-
-
- public static bool isFileLocked(string pathName)
- {
- try
- {
- if (!File.Exists(pathName))
- {
- return false;
- }
- using (var fs = new FileStream(pathName, FileMode.Open, FileAccess.Read, FileShare.None))
- {
-
- fs.Close();
- }
- }
- catch
- {
- return true;
- }
- return false;
- }
- }
- }
|