+++ /dev/null
-Imports System.IO
-Imports Microsoft.Win32
-
-Public Class MySpecialPath
-
- Public Shared ReadOnly Property UserAppDataPath() As String
- Get
- Return GetFileSystemPath(Environment.SpecialFolder.ApplicationData)
- End Get
- End Property
-
- Public Shared ReadOnly Property UserAppDataPath(ByVal productName As String) As String
- Get
- Return GetFileSystemPath(Environment.SpecialFolder.ApplicationData, productName)
- End Get
- End Property
-
- Public Shared ReadOnly Property CommonAppDataPath() As String
- Get
- Return GetFileSystemPath(Environment.SpecialFolder.CommonApplicationData)
- End Get
- End Property
-
- Public Shared ReadOnly Property LocalUserAppDataPath() As String
- Get
- Return GetFileSystemPath(Environment.SpecialFolder.LocalApplicationData)
- End Get
- End Property
-
- Public Shared ReadOnly Property CommonAppDataRegistry() As RegistryKey
- Get
- Return GetRegistryPath(Registry.LocalMachine)
- End Get
- End Property
-
- Public Shared ReadOnly Property UserAppDataRegistry() As RegistryKey
- Get
- Return GetRegistryPath(Registry.CurrentUser)
- End Get
- End Property
-
-
- Private Shared Function GetFileSystemPath(ByVal folder As Environment.SpecialFolder) As String
- ' パスを取得
- Dim path As String = String.Format("{0}{3}{1}{3}{2}", _
- Environment.GetFolderPath(folder), _
- Application.CompanyName, _
- Application.ProductName,
- System.IO.Path.DirectorySeparatorChar.ToString())
-
- ' パスのフォルダを作成
- SyncLock GetType(Application)
- If Not Directory.Exists(path) Then
- Directory.CreateDirectory(path)
- End If
- End SyncLock
- Return path
- End Function 'GetFileSystemPath
-
- Private Shared Function GetFileSystemPath(ByVal folder As Environment.SpecialFolder, ByVal productName As String) As String
- ' パスを取得
- Dim path As String = String.Format("{0}{3}{1}{3}{2}", _
- Environment.GetFolderPath(folder), _
- Application.CompanyName, _
- productName,
- System.IO.Path.DirectorySeparatorChar.ToString())
-
- ' パスのフォルダを作成
- SyncLock GetType(Application)
- If Not Directory.Exists(path) Then
- Directory.CreateDirectory(path)
- End If
- End SyncLock
- Return path
- End Function 'GetFileSystemPath
-
- Private Shared Function GetRegistryPath(ByVal key As RegistryKey) As RegistryKey
- ' パスを取得
- Dim basePath As String
- If key Is Registry.LocalMachine Then
- basePath = "SOFTWARE"
- Else
- basePath = "Software"
- End If
- Dim path As String = String.Format("{0}\{1}\{2}", _
- basePath, _
- Application.CompanyName, _
- Application.ProductName)
- ' パスのレジストリ・キーの取得(および作成)
- Return key.CreateSubKey(path)
- End Function 'GetRegistryPath
-End Class
\ No newline at end of file
<Compile Include="MyLists.vb">
<SubType>Form</SubType>
</Compile>
- <Compile Include="MySpecialPath.vb" />
<Compile Include="nicoms.vb" />
<Compile Include="Setting\SettingAtIdList.vb" />
<Compile Include="Setting\SettingLocal.vb" />
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Win32;
+using System.Windows.Forms;
+using System.IO;
+
+namespace Tween
+{
+ public class MySpecialPath
+ {
+ //public static string UserAppDataPath
+ //{
+ // get
+ // {
+ // return GetFileSystemPath(Environment.SpecialFolder.ApplicationData);
+ // }
+ //}
+ public static string UserAppDataPath()
+ {
+ return GetFileSystemPath(Environment.SpecialFolder.ApplicationData);
+ }
+
+ //public static string UserAppDataPath(string productName)
+ //{
+ // get
+ // {
+ // return GetFileSystemPath(Environment.SpecialFolder.ApplicationData, productName);
+ // }
+ //}
+ public static string UserAppDataPath(string productName)
+ {
+ return GetFileSystemPath(Environment.SpecialFolder.ApplicationData, productName);
+ }
+
+ public static string CommonAppDataPath
+ {
+ get
+ {
+ return GetFileSystemPath(Environment.SpecialFolder.CommonApplicationData);
+ }
+ }
+
+ public static string LocalUserAppDataPath
+ {
+ get
+ {
+ return GetFileSystemPath(Environment.SpecialFolder.LocalApplicationData);
+ }
+ }
+
+ public static RegistryKey CommonAppDataRegistry
+ {
+ get
+ {
+ return GetRegistryPath(Registry.LocalMachine);
+ }
+ }
+
+ public static RegistryKey UserAppDataRegistry
+ {
+ get
+ {
+ return GetRegistryPath(Registry.CurrentUser);
+ }
+ }
+
+
+ private static string GetFileSystemPath(Environment.SpecialFolder folder)
+ {
+ // パスを取得
+ var path = string.Format("{0}{3}{1}{3}{2}",
+ Environment.GetFolderPath(folder),
+ Application.CompanyName,
+ Application.ProductName,
+ Path.DirectorySeparatorChar.ToString());
+
+ // パスのフォルダを作成
+ lock (typeof(Application))
+ {
+ if (!Directory.Exists(path))
+ {
+ Directory.CreateDirectory(path);
+ }
+ }
+ return path;
+ }
+
+ private static string GetFileSystemPath(Environment.SpecialFolder folder, string productName)
+ {
+ // パスを取得
+ var path = string.Format("{0}{3}{1}{3}{2}",
+ Environment.GetFolderPath(folder),
+ Application.CompanyName,
+ productName,
+ Path.DirectorySeparatorChar.ToString());
+
+ // パスのフォルダを作成
+ lock (typeof(Application))
+ {
+ if (!Directory.Exists(path))
+ {
+ Directory.CreateDirectory(path);
+ }
+ }
+ return path;
+ }
+
+ private static RegistryKey GetRegistryPath(RegistryKey key)
+ {
+ // パスを取得
+ string basePath;
+ if (key == Registry.LocalMachine)
+ {
+ basePath = "SOFTWARE";
+ }
+ else
+ {
+ basePath = "Software";
+ }
+ var path = string.Format(@"{0}\{1}\{2}",
+ basePath,
+ Application.CompanyName,
+ Application.ProductName);
+ // パスのレジストリ・キーの取得(および作成)
+ return key.CreateSubKey(path);
+ }
+ }
+}
<Compile Include="DoubleClickCopyCanceller.cs" />
<Compile Include="Growl.cs" />
<Compile Include="MyCommon.cs" />
+ <Compile Include="MySpecialPath.cs" />
<Compile Include="OpenURL.cs">
<SubType>Form</SubType>
</Compile>